[PowerPC] folding rlwinm + rlwinm to rlwinm
For example:
x3 = rlwinm x3, 27, 5, 31
x3 = rlwinm x3, 19, 0, 12
can be combined to
x3 = rlwinm x3, 14, 0, 12
Reviewed by: steven.zhang, lkail
Differential Revision: https://reviews.llvm.org/D70374
2019-12-04 10:48:12 +08:00
|
|
|
# RUN: llc -ppc-asm-full-reg-names -mtriple=powerpc64le-unknown-linux-gnu \
|
|
|
|
# RUN: -run-pass ppc-mi-peepholes %s -o - -verify-machineinstrs | FileCheck %s
|
|
|
|
|
|
|
|
---
|
|
|
|
name: testFoldRLWINM
|
2020-04-09 00:34:28 +08:00
|
|
|
#CHECK: name: testFoldRLWINM
|
[PowerPC] folding rlwinm + rlwinm to rlwinm
For example:
x3 = rlwinm x3, 27, 5, 31
x3 = rlwinm x3, 19, 0, 12
can be combined to
x3 = rlwinm x3, 14, 0, 12
Reviewed by: steven.zhang, lkail
Differential Revision: https://reviews.llvm.org/D70374
2019-12-04 10:48:12 +08:00
|
|
|
tracksRegLiveness: true
|
|
|
|
body: |
|
|
|
|
bb.0.entry:
|
|
|
|
liveins: $x3
|
|
|
|
%0:g8rc = COPY $x3
|
|
|
|
%1:gprc = COPY %0.sub_32:g8rc
|
|
|
|
%2:gprc = RLWINM %1:gprc, 27, 5, 31
|
2019-12-23 23:26:41 +08:00
|
|
|
; CHECK-NOT: %2:gprc = RLWINM %1, 27, 5, 31
|
[PowerPC] folding rlwinm + rlwinm to rlwinm
For example:
x3 = rlwinm x3, 27, 5, 31
x3 = rlwinm x3, 19, 0, 12
can be combined to
x3 = rlwinm x3, 14, 0, 12
Reviewed by: steven.zhang, lkail
Differential Revision: https://reviews.llvm.org/D70374
2019-12-04 10:48:12 +08:00
|
|
|
%3:gprc = RLWINM %2:gprc, 19, 0, 12
|
|
|
|
; CHECK: %3:gprc = RLWINM %1, 14, 0, 12
|
|
|
|
BLR8 implicit $lr8, implicit $rm
|
|
|
|
...
|
|
|
|
---
|
|
|
|
name: testFoldRLWINMSrcFullMask1
|
2020-04-09 00:34:28 +08:00
|
|
|
#CHECK: name: testFoldRLWINMSrcFullMask1
|
[PowerPC] folding rlwinm + rlwinm to rlwinm
For example:
x3 = rlwinm x3, 27, 5, 31
x3 = rlwinm x3, 19, 0, 12
can be combined to
x3 = rlwinm x3, 14, 0, 12
Reviewed by: steven.zhang, lkail
Differential Revision: https://reviews.llvm.org/D70374
2019-12-04 10:48:12 +08:00
|
|
|
tracksRegLiveness: true
|
|
|
|
body: |
|
|
|
|
bb.0.entry:
|
|
|
|
liveins: $x3
|
|
|
|
%0:g8rc = COPY $x3
|
|
|
|
%1:gprc = COPY %0.sub_32:g8rc
|
|
|
|
%2:gprc = RLWINM %1:gprc, 27, 0, 31
|
2019-12-23 23:26:41 +08:00
|
|
|
; CHECK-NOT: %2:gprc = RLWINM %1, 27, 0, 31
|
[PowerPC] folding rlwinm + rlwinm to rlwinm
For example:
x3 = rlwinm x3, 27, 5, 31
x3 = rlwinm x3, 19, 0, 12
can be combined to
x3 = rlwinm x3, 14, 0, 12
Reviewed by: steven.zhang, lkail
Differential Revision: https://reviews.llvm.org/D70374
2019-12-04 10:48:12 +08:00
|
|
|
%3:gprc = RLWINM %2:gprc, 19, 0, 12
|
|
|
|
; CHECK: %3:gprc = RLWINM %1, 14, 0, 12
|
|
|
|
BLR8 implicit $lr8, implicit $rm
|
|
|
|
...
|
|
|
|
---
|
|
|
|
name: testFoldRLWINMSrcFullMask2
|
2020-04-09 00:34:28 +08:00
|
|
|
#CHECK: name: testFoldRLWINMSrcFullMask2
|
[PowerPC] folding rlwinm + rlwinm to rlwinm
For example:
x3 = rlwinm x3, 27, 5, 31
x3 = rlwinm x3, 19, 0, 12
can be combined to
x3 = rlwinm x3, 14, 0, 12
Reviewed by: steven.zhang, lkail
Differential Revision: https://reviews.llvm.org/D70374
2019-12-04 10:48:12 +08:00
|
|
|
tracksRegLiveness: true
|
|
|
|
body: |
|
|
|
|
bb.0.entry:
|
|
|
|
liveins: $x3
|
|
|
|
%0:g8rc = COPY $x3
|
|
|
|
%1:gprc = COPY %0.sub_32:g8rc
|
|
|
|
%2:gprc = RLWINM %1:gprc, 27, 10, 9
|
2019-12-23 23:26:41 +08:00
|
|
|
; CHECK-NOT: %2:gprc = RLWINM %1, 27, 10, 9
|
[PowerPC] folding rlwinm + rlwinm to rlwinm
For example:
x3 = rlwinm x3, 27, 5, 31
x3 = rlwinm x3, 19, 0, 12
can be combined to
x3 = rlwinm x3, 14, 0, 12
Reviewed by: steven.zhang, lkail
Differential Revision: https://reviews.llvm.org/D70374
2019-12-04 10:48:12 +08:00
|
|
|
%3:gprc = RLWINM %2:gprc, 19, 10, 1
|
|
|
|
; CHECK: %3:gprc = RLWINM %1, 14, 10, 1
|
|
|
|
BLR8 implicit $lr8, implicit $rm
|
|
|
|
...
|
|
|
|
---
|
|
|
|
name: testFoldRLWINMSrcWrapped
|
2020-04-09 00:34:28 +08:00
|
|
|
#CHECK: name: testFoldRLWINMSrcWrapped
|
[PowerPC] folding rlwinm + rlwinm to rlwinm
For example:
x3 = rlwinm x3, 27, 5, 31
x3 = rlwinm x3, 19, 0, 12
can be combined to
x3 = rlwinm x3, 14, 0, 12
Reviewed by: steven.zhang, lkail
Differential Revision: https://reviews.llvm.org/D70374
2019-12-04 10:48:12 +08:00
|
|
|
tracksRegLiveness: true
|
|
|
|
body: |
|
|
|
|
bb.0.entry:
|
|
|
|
liveins: $x3
|
|
|
|
%0:g8rc = COPY $x3
|
|
|
|
%1:gprc = COPY %0.sub_32:g8rc
|
|
|
|
%2:gprc = RLWINM %1:gprc, 27, 30, 10
|
2019-12-23 23:26:41 +08:00
|
|
|
; CHECK-NOT: %2:gprc = RLWINM %1, 27, 30, 10
|
[PowerPC] folding rlwinm + rlwinm to rlwinm
For example:
x3 = rlwinm x3, 27, 5, 31
x3 = rlwinm x3, 19, 0, 12
can be combined to
x3 = rlwinm x3, 14, 0, 12
Reviewed by: steven.zhang, lkail
Differential Revision: https://reviews.llvm.org/D70374
2019-12-04 10:48:12 +08:00
|
|
|
%3:gprc = RLWINM %2:gprc, 19, 0, 12
|
|
|
|
; CHECK: %3:gprc = RLWINM %1, 14, 11, 12
|
|
|
|
BLR8 implicit $lr8, implicit $rm
|
|
|
|
...
|
|
|
|
---
|
|
|
|
name: testFoldRLWINMUserWrapped
|
2020-04-09 00:34:28 +08:00
|
|
|
#CHECK: name: testFoldRLWINMUserWrapped
|
[PowerPC] folding rlwinm + rlwinm to rlwinm
For example:
x3 = rlwinm x3, 27, 5, 31
x3 = rlwinm x3, 19, 0, 12
can be combined to
x3 = rlwinm x3, 14, 0, 12
Reviewed by: steven.zhang, lkail
Differential Revision: https://reviews.llvm.org/D70374
2019-12-04 10:48:12 +08:00
|
|
|
tracksRegLiveness: true
|
|
|
|
body: |
|
|
|
|
bb.0.entry:
|
|
|
|
liveins: $x3
|
|
|
|
%0:g8rc = COPY $x3
|
|
|
|
%1:gprc = COPY %0.sub_32:g8rc
|
|
|
|
%2:gprc = RLWINM %1:gprc, 10, 5, 31
|
2019-12-23 23:26:41 +08:00
|
|
|
; CHECK: %2:gprc = RLWINM %1, 10, 5, 31
|
[PowerPC] folding rlwinm + rlwinm to rlwinm
For example:
x3 = rlwinm x3, 27, 5, 31
x3 = rlwinm x3, 19, 0, 12
can be combined to
x3 = rlwinm x3, 14, 0, 12
Reviewed by: steven.zhang, lkail
Differential Revision: https://reviews.llvm.org/D70374
2019-12-04 10:48:12 +08:00
|
|
|
%3:gprc = RLWINM %2:gprc, 10, 30, 5
|
|
|
|
; CHECK: %3:gprc = RLWINM %2, 10, 30, 5
|
|
|
|
BLR8 implicit $lr8, implicit $rm
|
|
|
|
...
|
|
|
|
---
|
[PowerPC] stop folding if result rlwinm mask is wrap while original rlwinm is not.
%1:g8rc = RLWINM8 %0:g8rc, 0, 16, 9
%2:g8rc = RLWINM8 killed %1:g8rc, 0, 0, 31
->
%2:g8rc = RLWINM8 %0:g8rc, 0, 16, 9
The above folding is wrong. Before transformation, %2:g8rc is 32 bit value. After
transformation, %2:g8rc becomes a 64 bit value.
This patch fixes above issue.
Reviewed by: steven.zhang
Differential Revision: https://reviews.llvm.org/D71833
2019-12-26 10:52:56 +08:00
|
|
|
name: testFoldRLWINMResultWrapped
|
2020-04-09 00:34:28 +08:00
|
|
|
#CHECK: name: testFoldRLWINMResultWrapped
|
[PowerPC] stop folding if result rlwinm mask is wrap while original rlwinm is not.
%1:g8rc = RLWINM8 %0:g8rc, 0, 16, 9
%2:g8rc = RLWINM8 killed %1:g8rc, 0, 0, 31
->
%2:g8rc = RLWINM8 %0:g8rc, 0, 16, 9
The above folding is wrong. Before transformation, %2:g8rc is 32 bit value. After
transformation, %2:g8rc becomes a 64 bit value.
This patch fixes above issue.
Reviewed by: steven.zhang
Differential Revision: https://reviews.llvm.org/D71833
2019-12-26 10:52:56 +08:00
|
|
|
tracksRegLiveness: true
|
|
|
|
body: |
|
|
|
|
bb.0.entry:
|
|
|
|
liveins: $x3
|
|
|
|
%0:g8rc = COPY $x3
|
|
|
|
%1:gprc = COPY %0.sub_32:g8rc
|
|
|
|
%2:gprc = RLWINM %1:gprc, 10, 20, 10
|
|
|
|
; CHECK: %2:gprc = RLWINM %1, 10, 20, 10
|
|
|
|
%3:gprc = RLWINM %2:gprc, 10, 0, 31
|
|
|
|
; CHECK: %3:gprc = RLWINM %2, 10, 0, 31
|
|
|
|
BLR8 implicit $lr8, implicit $rm
|
|
|
|
...
|
|
|
|
---
|
[PowerPC] folding rlwinm + rlwinm to rlwinm
For example:
x3 = rlwinm x3, 27, 5, 31
x3 = rlwinm x3, 19, 0, 12
can be combined to
x3 = rlwinm x3, 14, 0, 12
Reviewed by: steven.zhang, lkail
Differential Revision: https://reviews.llvm.org/D70374
2019-12-04 10:48:12 +08:00
|
|
|
name: testFoldRLWINMMultipleUses
|
2020-04-09 00:34:28 +08:00
|
|
|
#CHECK: name: testFoldRLWINMMultipleUses
|
[PowerPC] folding rlwinm + rlwinm to rlwinm
For example:
x3 = rlwinm x3, 27, 5, 31
x3 = rlwinm x3, 19, 0, 12
can be combined to
x3 = rlwinm x3, 14, 0, 12
Reviewed by: steven.zhang, lkail
Differential Revision: https://reviews.llvm.org/D70374
2019-12-04 10:48:12 +08:00
|
|
|
tracksRegLiveness: true
|
|
|
|
body: |
|
|
|
|
bb.0.entry:
|
|
|
|
liveins: $x3
|
|
|
|
%0:g8rc = COPY $x3
|
|
|
|
%1:gprc = COPY %0.sub_32:g8rc
|
|
|
|
%2:gprc = RLWINM killed %1:gprc, 27, 5, 31
|
|
|
|
; CHECK: %2:gprc = RLWINM %1, 27, 5, 31
|
|
|
|
%3:gprc = RLWINM %2:gprc, 19, 0, 12
|
|
|
|
; CHECK: %3:gprc = RLWINM killed %1, 14, 0, 12
|
|
|
|
STW %3:gprc, %2:gprc, 100
|
|
|
|
; CHECK: STW %3, %2, 100
|
|
|
|
BLR8 implicit $lr8, implicit $rm
|
|
|
|
...
|
|
|
|
---
|
|
|
|
name: testFoldRLWINMToZero
|
2020-04-09 00:34:28 +08:00
|
|
|
#CHECK: name: testFoldRLWINMToZero
|
[PowerPC] folding rlwinm + rlwinm to rlwinm
For example:
x3 = rlwinm x3, 27, 5, 31
x3 = rlwinm x3, 19, 0, 12
can be combined to
x3 = rlwinm x3, 14, 0, 12
Reviewed by: steven.zhang, lkail
Differential Revision: https://reviews.llvm.org/D70374
2019-12-04 10:48:12 +08:00
|
|
|
tracksRegLiveness: true
|
|
|
|
body: |
|
|
|
|
bb.0.entry:
|
|
|
|
liveins: $x3
|
|
|
|
%0:g8rc = COPY $x3
|
|
|
|
%1:gprc = COPY %0.sub_32:g8rc
|
|
|
|
%2:gprc = RLWINM %1:gprc, 27, 5, 10
|
[PowerPC] when folding rlwinm+rlwinm. to andi., we should use first rlwinm
input reg.
%2:gprc = RLWINM %1:gprc, 27, 5, 10
%3:gprc = RLWINM_rec %2:gprc, 8, 5, 10, implicit-def $cr0
==>
%3:gprc = ANDI_rec %1, 0, implicit-def $cr0
we should use %1 instead of %2 as ANDI_rec input.
Reviewed By: steven.zhang
Differential Revision: https://reviews.llvm.org/D71885
2020-01-09 09:54:15 +08:00
|
|
|
; CHECK-NOT: RLWINM %1,
|
[PowerPC] folding rlwinm + rlwinm to rlwinm
For example:
x3 = rlwinm x3, 27, 5, 31
x3 = rlwinm x3, 19, 0, 12
can be combined to
x3 = rlwinm x3, 14, 0, 12
Reviewed by: steven.zhang, lkail
Differential Revision: https://reviews.llvm.org/D70374
2019-12-04 10:48:12 +08:00
|
|
|
%3:gprc = RLWINM %2:gprc, 8, 5, 10
|
|
|
|
; CHECK: %3:gprc = LI 0
|
|
|
|
BLR8 implicit $lr8, implicit $rm
|
|
|
|
...
|
|
|
|
---
|
2020-01-07 03:05:12 +08:00
|
|
|
name: testFoldRLWINM_recToZero
|
2020-04-09 00:34:28 +08:00
|
|
|
#CHECK: name: testFoldRLWINM_recToZero
|
[PowerPC] folding rlwinm + rlwinm to rlwinm
For example:
x3 = rlwinm x3, 27, 5, 31
x3 = rlwinm x3, 19, 0, 12
can be combined to
x3 = rlwinm x3, 14, 0, 12
Reviewed by: steven.zhang, lkail
Differential Revision: https://reviews.llvm.org/D70374
2019-12-04 10:48:12 +08:00
|
|
|
tracksRegLiveness: true
|
|
|
|
body: |
|
|
|
|
bb.0.entry:
|
|
|
|
liveins: $x3
|
|
|
|
%0:g8rc = COPY $x3
|
|
|
|
%1:gprc = COPY %0.sub_32:g8rc
|
|
|
|
%2:gprc = RLWINM %1:gprc, 27, 5, 10
|
[PowerPC] when folding rlwinm+rlwinm. to andi., we should use first rlwinm
input reg.
%2:gprc = RLWINM %1:gprc, 27, 5, 10
%3:gprc = RLWINM_rec %2:gprc, 8, 5, 10, implicit-def $cr0
==>
%3:gprc = ANDI_rec %1, 0, implicit-def $cr0
we should use %1 instead of %2 as ANDI_rec input.
Reviewed By: steven.zhang
Differential Revision: https://reviews.llvm.org/D71885
2020-01-09 09:54:15 +08:00
|
|
|
; CHECK-NOT: RLWINM %1,
|
2020-01-07 03:05:12 +08:00
|
|
|
%3:gprc = RLWINM_rec %2:gprc, 8, 5, 10, implicit-def $cr0
|
[PowerPC] when folding rlwinm+rlwinm. to andi., we should use first rlwinm
input reg.
%2:gprc = RLWINM %1:gprc, 27, 5, 10
%3:gprc = RLWINM_rec %2:gprc, 8, 5, 10, implicit-def $cr0
==>
%3:gprc = ANDI_rec %1, 0, implicit-def $cr0
we should use %1 instead of %2 as ANDI_rec input.
Reviewed By: steven.zhang
Differential Revision: https://reviews.llvm.org/D71885
2020-01-09 09:54:15 +08:00
|
|
|
; CHECK: %3:gprc = ANDI_rec %1, 0, implicit-def $cr0
|
|
|
|
BLR8 implicit $lr8, implicit $rm
|
|
|
|
...
|
|
|
|
---
|
|
|
|
name: testFoldRLWINMoToZeroSrcCanNotBeDeleted
|
2020-04-09 00:34:28 +08:00
|
|
|
#CHECK: name: testFoldRLWINMoToZeroSrcCanNotBeDeleted
|
[PowerPC] when folding rlwinm+rlwinm. to andi., we should use first rlwinm
input reg.
%2:gprc = RLWINM %1:gprc, 27, 5, 10
%3:gprc = RLWINM_rec %2:gprc, 8, 5, 10, implicit-def $cr0
==>
%3:gprc = ANDI_rec %1, 0, implicit-def $cr0
we should use %1 instead of %2 as ANDI_rec input.
Reviewed By: steven.zhang
Differential Revision: https://reviews.llvm.org/D71885
2020-01-09 09:54:15 +08:00
|
|
|
tracksRegLiveness: true
|
|
|
|
body: |
|
|
|
|
bb.0.entry:
|
|
|
|
liveins: $x3
|
|
|
|
%0:g8rc = COPY $x3
|
|
|
|
%1:gprc = COPY %0.sub_32:g8rc
|
|
|
|
%2:gprc = RLWINM_rec %1:gprc, 27, 5, 10, implicit-def $cr0
|
|
|
|
; CHECK: %2:gprc = RLWINM_rec %1, 27, 5, 10, implicit-def $cr0
|
|
|
|
%3:gprc = RLWINM_rec %2:gprc, 8, 5, 10, implicit-def $cr0
|
|
|
|
; CHECK: %3:gprc = ANDI_rec %1, 0, implicit-def $cr0
|
[PowerPC] folding rlwinm + rlwinm to rlwinm
For example:
x3 = rlwinm x3, 27, 5, 31
x3 = rlwinm x3, 19, 0, 12
can be combined to
x3 = rlwinm x3, 14, 0, 12
Reviewed by: steven.zhang, lkail
Differential Revision: https://reviews.llvm.org/D70374
2019-12-04 10:48:12 +08:00
|
|
|
BLR8 implicit $lr8, implicit $rm
|
|
|
|
...
|
|
|
|
---
|
|
|
|
name: testFoldRLWINMInvalidMask
|
2020-04-09 00:34:28 +08:00
|
|
|
#CHECK: name: testFoldRLWINMInvalidMask
|
[PowerPC] folding rlwinm + rlwinm to rlwinm
For example:
x3 = rlwinm x3, 27, 5, 31
x3 = rlwinm x3, 19, 0, 12
can be combined to
x3 = rlwinm x3, 14, 0, 12
Reviewed by: steven.zhang, lkail
Differential Revision: https://reviews.llvm.org/D70374
2019-12-04 10:48:12 +08:00
|
|
|
tracksRegLiveness: true
|
|
|
|
body: |
|
|
|
|
bb.0.entry:
|
|
|
|
liveins: $x3
|
|
|
|
%0:g8rc = COPY $x3
|
|
|
|
%1:gprc = COPY %0.sub_32:g8rc
|
|
|
|
%2:gprc = RLWINM %1:gprc, 20, 5, 31
|
|
|
|
; CHECK: %2:gprc = RLWINM %1, 20, 5, 31
|
|
|
|
%3:gprc = RLWINM %2:gprc, 19, 10, 20
|
|
|
|
; CHECK: %3:gprc = RLWINM %2, 19, 10, 20
|
|
|
|
BLR8 implicit $lr8, implicit $rm
|
|
|
|
...
|
2020-06-15 09:22:50 +08:00
|
|
|
---
|
|
|
|
name: testFoldRLWINMLIWrapMask
|
|
|
|
#CHECK: name: testFoldRLWINMLIWrapMask
|
|
|
|
tracksRegLiveness: true
|
|
|
|
body: |
|
|
|
|
bb.0.entry:
|
|
|
|
liveins: $x3
|
|
|
|
%0:gprc = COPY $x3
|
|
|
|
%1:gprc = LI 100
|
|
|
|
; CHECK: %2:gprc = LI 200
|
|
|
|
%2:gprc = RLWINM %1:gprc, 1, 3, 2
|
|
|
|
STW %2:gprc, %0:gprc, 100
|
|
|
|
BLR8 implicit $lr8, implicit $rm
|
|
|
|
...
|