fold-rlwinm.mir 4.69 KB
# 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
#CHECK : name : testFoldRLWINM
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
    ; CHECK-NOT: %2:gprc = RLWINM %1, 27, 5, 31
    %3:gprc = RLWINM %2:gprc, 19, 0, 12
    ; CHECK: %3:gprc = RLWINM %1, 14, 0, 12
    BLR8 implicit $lr8, implicit $rm
...
---
name: testFoldRLWINMSrcFullMask1
#CHECK : name : testFoldRLWINMSrcFullMask1
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
    ; CHECK-NOT: %2:gprc = RLWINM %1, 27, 0, 31
    %3:gprc = RLWINM %2:gprc, 19, 0, 12
    ; CHECK: %3:gprc = RLWINM %1, 14, 0, 12
    BLR8 implicit $lr8, implicit $rm
...
---
name: testFoldRLWINMSrcFullMask2
#CHECK : name : testFoldRLWINMSrcFullMask2
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 
    ; CHECK-NOT: %2:gprc = RLWINM %1, 27, 10, 9
    %3:gprc = RLWINM %2:gprc, 19, 10, 1
    ; CHECK: %3:gprc = RLWINM %1, 14, 10, 1
    BLR8 implicit $lr8, implicit $rm
...
---
name: testFoldRLWINMSrcWrapped
#CHECK : name : testFoldRLWINMSrcWrapped
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
    ; CHECK-NOT: %2:gprc = RLWINM %1, 27, 30, 10 
    %3:gprc = RLWINM %2:gprc, 19, 0, 12
    ; CHECK: %3:gprc = RLWINM %1, 14, 11, 12
    BLR8 implicit $lr8, implicit $rm
...
---
name: testFoldRLWINMUserWrapped
#CHECK : name : testFoldRLWINMUserWrapped
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
    ; CHECK: %2:gprc = RLWINM %1, 10, 5, 31
    %3:gprc = RLWINM %2:gprc, 10, 30, 5
    ; CHECK: %3:gprc = RLWINM %2, 10, 30, 5
    BLR8 implicit $lr8, implicit $rm
...
---
name: testFoldRLWINMResultWrapped
#CHECK : name : testFoldRLWINMResultWrapped
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
...
---
name: testFoldRLWINMMultipleUses
#CHECK : name : testFoldRLWINMMultipleUses
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
#CHECK : name : testFoldRLWINMToZero
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
    ; CHECK-NOT: RLWINM %1,
    %3:gprc = RLWINM %2:gprc, 8, 5, 10
    ; CHECK: %3:gprc = LI 0
    BLR8 implicit $lr8, implicit $rm
...
---
name: testFoldRLWINM_recToZero
#CHECK : name : testFoldRLWINM_recToZero
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
    ; CHECK-NOT: RLWINM %1,
    %3:gprc = RLWINM_rec %2:gprc, 8, 5, 10, implicit-def $cr0
    ; CHECK: %3:gprc = ANDI_rec %1, 0, implicit-def $cr0
    BLR8 implicit $lr8, implicit $rm
...
---
name: testFoldRLWINMoToZeroSrcCanNotBeDeleted
#CHECK : name : testFoldRLWINMoToZeroSrcCanNotBeDeleted
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
    BLR8 implicit $lr8, implicit $rm
...
---
name: testFoldRLWINMInvalidMask
#CHECK : name : testFoldRLWINMInvalidMask
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
...