[PowerPC] Remove CRBits Copy Of Unset/set CBit
For the situation, where we generate the following code:
crxor 8, 8, 8
< Some instructions>
.LBB0_1:
< Some instructions>
cror 1, 8, 8
cror (COPY of CRbit) depends on the result of the crxor instruction.
CR8 is known to be zero as crxor is equivalent to CRUNSET. We can simply use
crxor 1, 1, 1 instead to zero out CR1, which does not have any dependency on
any previous instruction.
This patch will optimize it to:
< Some instructions>
.LBB0_1:
< Some instructions>
cror 1, 1, 1
Patch By: Victor Huang (NeHuang)
Differential Revision: https://reviews.llvm.org/D62044
llvm-svn: 361632
2019-05-24 14:05:37 +02:00
|
|
|
# RUN: llc -run-pass simple-register-coalescing %s -o - | FileCheck %s
|
|
|
|
--- |
|
|
|
|
target datalayout = "e-m:e-i64:64-n32:64"
|
|
|
|
target triple = "powerpc64le-unknown-linux-gnu"
|
|
|
|
|
|
|
|
@b = common dso_local local_unnamed_addr global i32 0, align 4
|
|
|
|
@d = common dso_local local_unnamed_addr global i32 0, align 4
|
|
|
|
@e = common dso_local local_unnamed_addr global i32* null, align 8
|
|
|
|
@c = common dso_local local_unnamed_addr global i32 0, align 4
|
|
|
|
@a = common dso_local local_unnamed_addr global [1 x i32] zeroinitializer, align 4
|
|
|
|
|
|
|
|
; Function Attrs: norecurse nounwind
|
|
|
|
define dso_local signext i32 @copycrunset() local_unnamed_addr #0 {
|
|
|
|
entry:
|
|
|
|
%0 = load i32, i32* @b, align 4
|
|
|
|
%tobool3 = icmp eq i32 %0, 0
|
|
|
|
br i1 %tobool3, label %while.end, label %while.body.preheader
|
|
|
|
|
|
|
|
while.body.preheader: ; preds = %entry
|
|
|
|
%.pre = load i32, i32* @d, align 4
|
|
|
|
%tobool1 = icmp eq i32 %.pre, 0
|
|
|
|
br label %while.body
|
|
|
|
|
|
|
|
while.body: ; preds = %land.end, %while.body.preheader
|
|
|
|
br i1 %tobool1, label %land.end, label %land.rhs
|
|
|
|
|
|
|
|
land.rhs: ; preds = %while.body
|
|
|
|
%1 = load i32*, i32** @e, align 8
|
|
|
|
%2 = load i32, i32* %1, align 4
|
|
|
|
%idxprom = sext i32 %2 to i64
|
|
|
|
%arrayidx = getelementptr inbounds [1 x i32], [1 x i32]* @a, i64 0, i64 %idxprom
|
|
|
|
%3 = load i32, i32* %arrayidx, align 4
|
|
|
|
%tobool2 = icmp ne i32 %3, 0
|
|
|
|
br label %land.end
|
|
|
|
|
|
|
|
land.end: ; preds = %land.rhs, %while.body
|
|
|
|
%4 = phi i1 [ false, %while.body ], [ %tobool2, %land.rhs ]
|
|
|
|
%land.ext = zext i1 %4 to i32
|
|
|
|
store i32 %land.ext, i32* @c, align 4
|
|
|
|
br label %while.body
|
|
|
|
|
|
|
|
while.end: ; preds = %entry
|
|
|
|
ret i32 undef
|
|
|
|
}
|
|
|
|
|
|
|
|
...
|
|
|
|
---
|
|
|
|
name: copycrunset
|
[Alignment] Use llvm::Align in MachineFunction and TargetLowering - fixes mir parsing
Summary:
This catches malformed mir files which specify alignment as log2 instead of pow2.
See https://reviews.llvm.org/D65945 for reference,
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790
Reviewers: courbet
Subscribers: MatzeB, qcolombet, dschuff, arsenm, sdardis, nemanjai, jvesely, nhaehnle, hiraditya, kbarton, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, jsji, Petar.Avramovic, asbirlea, s.egerton, pzheng, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67433
llvm-svn: 371608
2019-09-11 13:16:48 +02:00
|
|
|
alignment: 16
|
[PowerPC] Remove CRBits Copy Of Unset/set CBit
For the situation, where we generate the following code:
crxor 8, 8, 8
< Some instructions>
.LBB0_1:
< Some instructions>
cror 1, 8, 8
cror (COPY of CRbit) depends on the result of the crxor instruction.
CR8 is known to be zero as crxor is equivalent to CRUNSET. We can simply use
crxor 1, 1, 1 instead to zero out CR1, which does not have any dependency on
any previous instruction.
This patch will optimize it to:
< Some instructions>
.LBB0_1:
< Some instructions>
cror 1, 1, 1
Patch By: Victor Huang (NeHuang)
Differential Revision: https://reviews.llvm.org/D62044
llvm-svn: 361632
2019-05-24 14:05:37 +02:00
|
|
|
exposesReturnsTwice: false
|
|
|
|
legalized: false
|
|
|
|
regBankSelected: false
|
|
|
|
selected: false
|
|
|
|
failedISel: false
|
|
|
|
tracksRegLiveness: true
|
|
|
|
hasWinCFI: false
|
|
|
|
registers:
|
|
|
|
- { id: 0, class: crbitrc, preferred-register: '' }
|
|
|
|
- { id: 1, class: crbitrc, preferred-register: '' }
|
|
|
|
- { id: 2, class: crbitrc, preferred-register: '' }
|
|
|
|
- { id: 3, class: g8rc_and_g8rc_nox0, preferred-register: '' }
|
|
|
|
- { id: 4, class: gprc, preferred-register: '' }
|
|
|
|
- { id: 5, class: crrc, preferred-register: '' }
|
|
|
|
- { id: 6, class: g8rc_and_g8rc_nox0, preferred-register: '' }
|
|
|
|
- { id: 7, class: gprc, preferred-register: '' }
|
|
|
|
- { id: 8, class: crrc, preferred-register: '' }
|
|
|
|
- { id: 9, class: crbitrc, preferred-register: '' }
|
|
|
|
- { id: 10, class: g8rc_and_g8rc_nox0, preferred-register: '' }
|
|
|
|
- { id: 11, class: g8rc_and_g8rc_nox0, preferred-register: '' }
|
|
|
|
- { id: 12, class: g8rc, preferred-register: '' }
|
|
|
|
- { id: 13, class: g8rc_and_g8rc_nox0, preferred-register: '' }
|
|
|
|
- { id: 14, class: g8rc_and_g8rc_nox0, preferred-register: '' }
|
|
|
|
- { id: 15, class: g8rc, preferred-register: '' }
|
|
|
|
- { id: 16, class: gprc, preferred-register: '' }
|
|
|
|
- { id: 17, class: crrc, preferred-register: '' }
|
|
|
|
- { id: 18, class: crbitrc, preferred-register: '' }
|
|
|
|
- { id: 19, class: gprc_and_gprc_nor0, preferred-register: '' }
|
|
|
|
- { id: 20, class: gprc_and_gprc_nor0, preferred-register: '' }
|
|
|
|
- { id: 21, class: gprc, preferred-register: '' }
|
|
|
|
- { id: 22, class: g8rc_and_g8rc_nox0, preferred-register: '' }
|
|
|
|
- { id: 23, class: g8rc, preferred-register: '' }
|
|
|
|
- { id: 24, class: crbitrc, preferred-register: '' }
|
|
|
|
liveins:
|
|
|
|
- { reg: '$x2', virtual-reg: '' }
|
|
|
|
frameInfo:
|
|
|
|
isFrameAddressTaken: false
|
|
|
|
isReturnAddressTaken: false
|
|
|
|
hasStackMap: false
|
|
|
|
hasPatchPoint: false
|
|
|
|
stackSize: 0
|
|
|
|
offsetAdjustment: 0
|
|
|
|
maxAlignment: 0
|
|
|
|
adjustsStack: false
|
|
|
|
hasCalls: false
|
|
|
|
stackProtector: ''
|
|
|
|
maxCallFrameSize: 4294967295
|
|
|
|
cvBytesOfCalleeSavedRegisters: 0
|
|
|
|
hasOpaqueSPAdjustment: false
|
|
|
|
hasVAStart: false
|
|
|
|
hasMustTailInVarArgFunc: false
|
|
|
|
localFrameSize: 0
|
|
|
|
savePoint: ''
|
|
|
|
restorePoint: ''
|
|
|
|
fixedStack: []
|
|
|
|
stack: []
|
|
|
|
constants: []
|
|
|
|
machineFunctionInfo: {}
|
|
|
|
body: |
|
|
|
|
bb.0.entry:
|
|
|
|
successors: %bb.5(0x30000000), %bb.1(0x50000000)
|
|
|
|
liveins: $x2
|
|
|
|
|
2019-07-22 21:55:33 +02:00
|
|
|
%3:g8rc_and_g8rc_nox0 = ADDIStocHA8 $x2, @b
|
2021-05-20 04:25:51 +02:00
|
|
|
%4:gprc = LWZ target-flags(ppc-toc-lo) @b, killed %3, implicit $x2 :: (dereferenceable load (s32) from @b)
|
[PowerPC] Remove CRBits Copy Of Unset/set CBit
For the situation, where we generate the following code:
crxor 8, 8, 8
< Some instructions>
.LBB0_1:
< Some instructions>
cror 1, 8, 8
cror (COPY of CRbit) depends on the result of the crxor instruction.
CR8 is known to be zero as crxor is equivalent to CRUNSET. We can simply use
crxor 1, 1, 1 instead to zero out CR1, which does not have any dependency on
any previous instruction.
This patch will optimize it to:
< Some instructions>
.LBB0_1:
< Some instructions>
cror 1, 1, 1
Patch By: Victor Huang (NeHuang)
Differential Revision: https://reviews.llvm.org/D62044
llvm-svn: 361632
2019-05-24 14:05:37 +02:00
|
|
|
%5:crrc = CMPLWI killed %4, 0
|
|
|
|
BCC 76, killed %5, %bb.5
|
|
|
|
B %bb.1
|
|
|
|
|
|
|
|
bb.1.while.body.preheader:
|
|
|
|
successors: %bb.2(0x80000000)
|
|
|
|
liveins: $x2
|
|
|
|
|
2019-07-22 21:55:33 +02:00
|
|
|
%6:g8rc_and_g8rc_nox0 = ADDIStocHA8 $x2, @d
|
2021-05-20 04:25:51 +02:00
|
|
|
%7:gprc = LWZ target-flags(ppc-toc-lo) @d, killed %6, implicit $x2 :: (dereferenceable load (s32) from @d)
|
[PowerPC] Remove CRBits Copy Of Unset/set CBit
For the situation, where we generate the following code:
crxor 8, 8, 8
< Some instructions>
.LBB0_1:
< Some instructions>
cror 1, 8, 8
cror (COPY of CRbit) depends on the result of the crxor instruction.
CR8 is known to be zero as crxor is equivalent to CRUNSET. We can simply use
crxor 1, 1, 1 instead to zero out CR1, which does not have any dependency on
any previous instruction.
This patch will optimize it to:
< Some instructions>
.LBB0_1:
< Some instructions>
cror 1, 1, 1
Patch By: Victor Huang (NeHuang)
Differential Revision: https://reviews.llvm.org/D62044
llvm-svn: 361632
2019-05-24 14:05:37 +02:00
|
|
|
%8:crrc = CMPWI killed %7, 0
|
|
|
|
%0:crbitrc = COPY killed %8.sub_eq
|
|
|
|
%9:crbitrc = CRUNSET
|
|
|
|
%19:gprc_and_gprc_nor0 = LI 0
|
|
|
|
%20:gprc_and_gprc_nor0 = LI 1
|
2019-07-22 21:55:33 +02:00
|
|
|
%22:g8rc_and_g8rc_nox0 = ADDIStocHA8 $x2, @c
|
|
|
|
%10:g8rc_and_g8rc_nox0 = ADDIStocHA8 $x2, @e
|
|
|
|
%13:g8rc_and_g8rc_nox0 = ADDIStocHA8 $x2, @a
|
[PowerPC] Remove CRBits Copy Of Unset/set CBit
For the situation, where we generate the following code:
crxor 8, 8, 8
< Some instructions>
.LBB0_1:
< Some instructions>
cror 1, 8, 8
cror (COPY of CRbit) depends on the result of the crxor instruction.
CR8 is known to be zero as crxor is equivalent to CRUNSET. We can simply use
crxor 1, 1, 1 instead to zero out CR1, which does not have any dependency on
any previous instruction.
This patch will optimize it to:
< Some instructions>
.LBB0_1:
< Some instructions>
cror 1, 1, 1
Patch By: Victor Huang (NeHuang)
Differential Revision: https://reviews.llvm.org/D62044
llvm-svn: 361632
2019-05-24 14:05:37 +02:00
|
|
|
%14:g8rc_and_g8rc_nox0 = ADDItocL killed %13, @a, implicit $x2
|
|
|
|
|
|
|
|
bb.2.while.body:
|
|
|
|
successors: %bb.4(0x30000000), %bb.3(0x50000000)
|
|
|
|
liveins: $x2
|
|
|
|
|
|
|
|
%24:crbitrc = COPY %9
|
|
|
|
BC %0, %bb.4
|
|
|
|
B %bb.3
|
|
|
|
|
|
|
|
bb.3.land.rhs:
|
|
|
|
successors: %bb.4(0x80000000)
|
|
|
|
liveins: $x2
|
|
|
|
|
2021-05-20 04:25:51 +02:00
|
|
|
%11:g8rc_and_g8rc_nox0 = LD target-flags(ppc-toc-lo) @e, %10, implicit $x2 :: (dereferenceable load (s64) from @e)
|
|
|
|
%12:g8rc = LWA 0, killed %11 :: (load (s32) from %ir.1)
|
[PowerPC] Remove CRBits Copy Of Unset/set CBit
For the situation, where we generate the following code:
crxor 8, 8, 8
< Some instructions>
.LBB0_1:
< Some instructions>
cror 1, 8, 8
cror (COPY of CRbit) depends on the result of the crxor instruction.
CR8 is known to be zero as crxor is equivalent to CRUNSET. We can simply use
crxor 1, 1, 1 instead to zero out CR1, which does not have any dependency on
any previous instruction.
This patch will optimize it to:
< Some instructions>
.LBB0_1:
< Some instructions>
cror 1, 1, 1
Patch By: Victor Huang (NeHuang)
Differential Revision: https://reviews.llvm.org/D62044
llvm-svn: 361632
2019-05-24 14:05:37 +02:00
|
|
|
%15:g8rc = RLDICR killed %12, 2, 61
|
2021-05-20 04:25:51 +02:00
|
|
|
%16:gprc = LWZX %14, killed %15 :: (load (s32) from %ir.arrayidx)
|
[PowerPC] Remove CRBits Copy Of Unset/set CBit
For the situation, where we generate the following code:
crxor 8, 8, 8
< Some instructions>
.LBB0_1:
< Some instructions>
cror 1, 8, 8
cror (COPY of CRbit) depends on the result of the crxor instruction.
CR8 is known to be zero as crxor is equivalent to CRUNSET. We can simply use
crxor 1, 1, 1 instead to zero out CR1, which does not have any dependency on
any previous instruction.
This patch will optimize it to:
< Some instructions>
.LBB0_1:
< Some instructions>
cror 1, 1, 1
Patch By: Victor Huang (NeHuang)
Differential Revision: https://reviews.llvm.org/D62044
llvm-svn: 361632
2019-05-24 14:05:37 +02:00
|
|
|
%17:crrc = CMPWI killed %16, 0
|
|
|
|
%18:crbitrc = COPY killed %17.sub_eq
|
|
|
|
%1:crbitrc = CRNOR killed %18, %18
|
|
|
|
%24:crbitrc = COPY killed %1
|
|
|
|
|
|
|
|
bb.4.land.end:
|
|
|
|
successors: %bb.2(0x80000000)
|
|
|
|
liveins: $x2
|
|
|
|
|
|
|
|
%2:crbitrc = COPY killed %24
|
|
|
|
%21:gprc = ISEL %20, %19, killed %2
|
2021-05-20 04:25:51 +02:00
|
|
|
STW killed %21, target-flags(ppc-toc-lo) @c, %22, implicit $x2 :: (store (s32) into @c)
|
[PowerPC] Remove CRBits Copy Of Unset/set CBit
For the situation, where we generate the following code:
crxor 8, 8, 8
< Some instructions>
.LBB0_1:
< Some instructions>
cror 1, 8, 8
cror (COPY of CRbit) depends on the result of the crxor instruction.
CR8 is known to be zero as crxor is equivalent to CRUNSET. We can simply use
crxor 1, 1, 1 instead to zero out CR1, which does not have any dependency on
any previous instruction.
This patch will optimize it to:
< Some instructions>
.LBB0_1:
< Some instructions>
cror 1, 1, 1
Patch By: Victor Huang (NeHuang)
Differential Revision: https://reviews.llvm.org/D62044
llvm-svn: 361632
2019-05-24 14:05:37 +02:00
|
|
|
B %bb.2
|
|
|
|
|
|
|
|
bb.5.while.end:
|
|
|
|
%23:g8rc = LI8 0
|
|
|
|
$x3 = COPY killed %23
|
|
|
|
BLR8 implicit $lr8, implicit $rm, implicit killed $x3
|
|
|
|
|
|
|
|
...
|
|
|
|
#Copy of CRUNSET should be removed in simple register coalescing pass
|
|
|
|
#CHECK-LABEL: copycrunset
|
|
|
|
#CHECK: bb.1.while.body.preheader:
|
|
|
|
#CHECK-NOT: %9:crbitrc = CRUNSET
|
|
|
|
#CHECK: bb.2.while.body:
|
|
|
|
#CHECK-NOT: %24:crbitrc = COPY %9
|
|
|
|
#CHECK: %24:crbitrc = CRUNSET
|
|
|
|
#CHECK: B %bb.3
|