llvm.org GIT mirror llvm / stable test / CodeGen / AMDGPU / GlobalISel / legalize-icmp.mir
stable

Tree @stable (Download .tar.gz)

legalize-icmp.mir @stableraw · history · blame

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -O0 -march=amdgcn -mcpu=fiji  -run-pass=legalizer %s -o - | FileCheck %s

---
name: test_icmp_s32
body: |
  bb.0.entry:
    liveins: $vgpr0
    ; CHECK-LABEL: name: test_icmp_s32
    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
    ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[C]](s32), [[COPY]]
    ; CHECK: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[ICMP]](s1), [[C]], [[COPY]]
    ; CHECK: $vgpr0 = COPY [[SELECT]](s32)
    %0:_(s32) = G_CONSTANT i32 0
    %1:_(s32) = COPY $vgpr0
    %2:_(s1) = G_ICMP intpred(ne), %0, %1
    %3:_(s32) = G_SELECT %2, %0, %1
    $vgpr0 = COPY %3
...

---
name: test_icmp_s64
body: |
  bb.0.entry:
    liveins: $vgpr0_vgpr1
    ; CHECK-LABEL: name: test_icmp_s64
    ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
    ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[C]](s64), [[COPY]]
    ; CHECK: [[SELECT:%[0-9]+]]:_(s64) = G_SELECT [[ICMP]](s1), [[C]], [[COPY]]
    ; CHECK: $vgpr0_vgpr1 = COPY [[SELECT]](s64)
    %0:_(s64) = G_CONSTANT i64 0
    %1:_(s64) = COPY $vgpr0_vgpr1
    %2:_(s1) = G_ICMP intpred(ne), %0, %1
    %3:_(s64) = G_SELECT %2, %0, %1
    $vgpr0_vgpr1 = COPY %3
...

---
name: test_icmp_s16
body: |
  bb.0.entry:
    liveins: $vgpr0
    ; CHECK-LABEL: name: test_icmp_s16
    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
    ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
    ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[C]](s32)
    ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C1]]
    ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
    ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C1]]
    ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[AND]](s32), [[AND1]]
    ; CHECK: [[COPY3:%[0-9]+]]:_(s32) = COPY [[C]](s32)
    ; CHECK: [[COPY4:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
    ; CHECK: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[ICMP]](s1), [[COPY3]], [[COPY4]]
    ; CHECK: [[COPY5:%[0-9]+]]:_(s32) = COPY [[SELECT]](s32)
    ; CHECK: $vgpr0 = COPY [[COPY5]](s32)
    %0:_(s16) = G_CONSTANT i16 0
    %1:_(s32) = COPY $vgpr0
    %2:_(s16) = G_TRUNC %1
    %3:_(s1) = G_ICMP intpred(ne), %0, %2
    %4:_(s16) = G_SELECT %3, %0, %2
    %5:_(s32) = G_ANYEXT %4
    $vgpr0 = COPY %5
...

---
name: test_icmp_s8
body: |
  bb.0.entry:
    liveins: $vgpr0
    ; CHECK-LABEL: name: test_icmp_s8
    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
    ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
    ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[C]](s32)
    ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C1]]
    ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
    ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C1]]
    ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[AND]](s32), [[AND1]]
    ; CHECK: [[COPY3:%[0-9]+]]:_(s32) = COPY [[C]](s32)
    ; CHECK: [[COPY4:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
    ; CHECK: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[ICMP]](s1), [[COPY3]], [[COPY4]]
    ; CHECK: [[COPY5:%[0-9]+]]:_(s32) = COPY [[SELECT]](s32)
    ; CHECK: $vgpr0 = COPY [[COPY5]](s32)
    %0:_(s8) = G_CONSTANT i8 0
    %1:_(s32) = COPY $vgpr0
    %2:_(s8) = G_TRUNC %1
    %3:_(s1) = G_ICMP intpred(ne), %0, %2
    %4:_(s8) = G_SELECT %3, %0, %2
    %5:_(s32) = G_ANYEXT %4
    $vgpr0 = COPY %5
...

---
name: test_icmp_v2s32
body: |
  bb.0.entry:
    liveins: $vgpr0_vgpr1
    ; CHECK-LABEL: name: test_icmp_v2s32
    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
    ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr0_vgpr1
    ; CHECK: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<2 x s32>)
    ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[C]](s32), [[UV]]
    ; CHECK: [[ICMP1:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[C]](s32), [[UV1]]
    ; CHECK: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s1>) = G_BUILD_VECTOR [[ICMP]](s1), [[ICMP1]](s1)
    ; CHECK: S_NOP 0, implicit [[BUILD_VECTOR]](<2 x s1>)
    %0:_(s32) = G_CONSTANT i32 0
    %1:_(<2 x s32>) = G_BUILD_VECTOR %0, %0
    %2:_(<2 x s32>) = COPY $vgpr0_vgpr1
    %3:_(<2 x s1>) = G_ICMP intpred(ne), %1, %2
    S_NOP 0, implicit %3
...

---
name: test_icmp_v3s32
body: |
  bb.0.entry:
    liveins: $vgpr0_vgpr1_vgpr2

    ; CHECK-LABEL: name: test_icmp_v3s32
    ; CHECK: [[DEF:%[0-9]+]]:_(<3 x s32>) = G_IMPLICIT_DEF
    ; CHECK: [[COPY:%[0-9]+]]:_(<3 x s32>) = COPY $vgpr0_vgpr1_vgpr2
    ; CHECK: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32), [[UV2:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[DEF]](<3 x s32>)
    ; CHECK: [[UV3:%[0-9]+]]:_(s32), [[UV4:%[0-9]+]]:_(s32), [[UV5:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<3 x s32>)
    ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[UV]](s32), [[UV3]]
    ; CHECK: [[ICMP1:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[UV1]](s32), [[UV4]]
    ; CHECK: [[ICMP2:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[UV2]](s32), [[UV5]]
    ; CHECK: [[BUILD_VECTOR:%[0-9]+]]:_(<3 x s1>) = G_BUILD_VECTOR [[ICMP]](s1), [[ICMP1]](s1), [[ICMP2]](s1)
    ; CHECK: S_NOP 0, implicit [[BUILD_VECTOR]](<3 x s1>)
    %0:_(<3 x s32>) = G_IMPLICIT_DEF
    %1:_(<3 x s32>) = COPY $vgpr0_vgpr1_vgpr2
    %2:_(<3 x s1>) = G_ICMP intpred(ne), %0, %1
    S_NOP 0, implicit %2
...

---
name: test_icmp_v4s32
body: |
  bb.0.entry:
    liveins: $vgpr0_vgpr1_vgpr2_vgpr3

    ; CHECK-LABEL: name: test_icmp_v4s32
    ; CHECK: [[DEF:%[0-9]+]]:_(p1) = G_IMPLICIT_DEF
    ; CHECK: [[LOAD:%[0-9]+]]:_(<4 x s32>) = G_LOAD [[DEF]](p1) :: (volatile load 16)
    ; CHECK: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
    ; CHECK: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32), [[UV2:%[0-9]+]]:_(s32), [[UV3:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[LOAD]](<4 x s32>)
    ; CHECK: [[UV4:%[0-9]+]]:_(s32), [[UV5:%[0-9]+]]:_(s32), [[UV6:%[0-9]+]]:_(s32), [[UV7:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<4 x s32>)
    ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[UV]](s32), [[UV4]]
    ; CHECK: [[ICMP1:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[UV1]](s32), [[UV5]]
    ; CHECK: [[ICMP2:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[UV2]](s32), [[UV6]]
    ; CHECK: [[ICMP3:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[UV3]](s32), [[UV7]]
    ; CHECK: [[BUILD_VECTOR:%[0-9]+]]:_(<4 x s1>) = G_BUILD_VECTOR [[ICMP]](s1), [[ICMP1]](s1), [[ICMP2]](s1), [[ICMP3]](s1)
    ; CHECK: S_NOP 0, implicit [[BUILD_VECTOR]](<4 x s1>)
    %0:_(p1) = G_IMPLICIT_DEF
    %1:_(<4 x s32>) = G_LOAD %0 :: (volatile load 16)
    %2:_(<4 x s32>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
    %3:_(<4 x s1>) = G_ICMP intpred(ne), %1, %2
    S_NOP 0, implicit %3

...

---
name: test_icmp_p0
body: |
  bb.0.entry:
    liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
    ; CHECK-LABEL: name: test_icmp_p0
    ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $vgpr0_vgpr1
    ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $vgpr0_vgpr1
    ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[COPY]](p0), [[COPY1]]
    ; CHECK: [[SEXT:%[0-9]+]]:_(s32) = G_SEXT [[ICMP]](s1)
    ; CHECK: $vgpr0 = COPY [[SEXT]](s32)
    %0:_(p0) = COPY $vgpr0_vgpr1
    %1:_(p0) = COPY $vgpr0_vgpr1
    %2:_(s1) = G_ICMP intpred(ne), %0, %1
    %3:_(s32) = G_SEXT %2
    $vgpr0 = COPY %3
...

---
name: test_icmp_p1
body: |
  bb.0.entry:
    liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
    ; CHECK-LABEL: name: test_icmp_p1
    ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
    ; CHECK: [[COPY1:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
    ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[COPY]](p1), [[COPY1]]
    ; CHECK: [[SEXT:%[0-9]+]]:_(s32) = G_SEXT [[ICMP]](s1)
    ; CHECK: $vgpr0 = COPY [[SEXT]](s32)
    %0:_(p1) = COPY $vgpr0_vgpr1
    %1:_(p1) = COPY $vgpr0_vgpr1
    %2:_(s1) = G_ICMP intpred(ne), %0, %1
    %3:_(s32) = G_SEXT %2
    $vgpr0 = COPY %3
...

---
name: test_icmp_p2
body: |
  bb.0.entry:
    liveins: $vgpr0, $vgpr1

    ; CHECK-LABEL: name: test_icmp_p2
    ; CHECK: [[COPY:%[0-9]+]]:_(p2) = COPY $vgpr0
    ; CHECK: [[COPY1:%[0-9]+]]:_(p2) = COPY $vgpr1
    ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[COPY]](p2), [[COPY1]]
    ; CHECK: [[SEXT:%[0-9]+]]:_(s32) = G_SEXT [[ICMP]](s1)
    ; CHECK: $vgpr0 = COPY [[SEXT]](s32)
    %0:_(p2) = COPY $vgpr0
    %1:_(p2) = COPY $vgpr1
    %2:_(s1) = G_ICMP intpred(ne), %0, %1
    %3:_(s32) = G_SEXT %2
    $vgpr0 = COPY %3
...

---
name: test_icmp_p3
body: |
  bb.0.entry:
    liveins: $vgpr0, $vgpr1

    ; CHECK-LABEL: name: test_icmp_p3
    ; CHECK: [[COPY:%[0-9]+]]:_(p3) = COPY $vgpr0
    ; CHECK: [[COPY1:%[0-9]+]]:_(p3) = COPY $vgpr1
    ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[COPY]](p3), [[COPY1]]
    ; CHECK: [[SEXT:%[0-9]+]]:_(s32) = G_SEXT [[ICMP]](s1)
    ; CHECK: $vgpr0 = COPY [[SEXT]](s32)
    %0:_(p3) = COPY $vgpr0
    %1:_(p3) = COPY $vgpr1
    %2:_(s1) = G_ICMP intpred(ne), %0, %1
    %3:_(s32) = G_SEXT %2
    $vgpr0 = COPY %3
...

---
name: test_icmp_p4
body: |
  bb.0.entry:
    liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
    ; CHECK-LABEL: name: test_icmp_p4
    ; CHECK: [[COPY:%[0-9]+]]:_(p4) = COPY $vgpr0_vgpr1
    ; CHECK: [[COPY1:%[0-9]+]]:_(p4) = COPY $vgpr0_vgpr1
    ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[COPY]](p4), [[COPY1]]
    ; CHECK: [[SEXT:%[0-9]+]]:_(s32) = G_SEXT [[ICMP]](s1)
    ; CHECK: $vgpr0 = COPY [[SEXT]](s32)
    %0:_(p4) = COPY $vgpr0_vgpr1
    %1:_(p4) = COPY $vgpr0_vgpr1
    %2:_(s1) = G_ICMP intpred(ne), %0, %1
    %3:_(s32) = G_SEXT %2
    $vgpr0 = COPY %3
...

---
name: test_icmp_p5
body: |
  bb.0.entry:
    liveins: $vgpr0, $vgpr1

    ; CHECK-LABEL: name: test_icmp_p5
    ; CHECK: [[COPY:%[0-9]+]]:_(p5) = COPY $vgpr0
    ; CHECK: [[COPY1:%[0-9]+]]:_(p5) = COPY $vgpr1
    ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[COPY]](p5), [[COPY1]]
    ; CHECK: [[SEXT:%[0-9]+]]:_(s32) = G_SEXT [[ICMP]](s1)
    ; CHECK: $vgpr0 = COPY [[SEXT]](s32)
    %0:_(p5) = COPY $vgpr0
    %1:_(p5) = COPY $vgpr1
    %2:_(s1) = G_ICMP intpred(ne), %0, %1
    %3:_(s32) = G_SEXT %2
    $vgpr0 = COPY %3
...

---
name: test_icmp_p999
body: |
  bb.0.entry:
    liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
    ; CHECK-LABEL: name: test_icmp_p999
    ; CHECK: [[COPY:%[0-9]+]]:_(p999) = COPY $vgpr0_vgpr1
    ; CHECK: [[COPY1:%[0-9]+]]:_(p999) = COPY $vgpr0_vgpr1
    ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[COPY]](p999), [[COPY1]]
    ; CHECK: [[SEXT:%[0-9]+]]:_(s32) = G_SEXT [[ICMP]](s1)
    ; CHECK: $vgpr0 = COPY [[SEXT]](s32)
    %0:_(p999) = COPY $vgpr0_vgpr1
    %1:_(p999) = COPY $vgpr0_vgpr1
    %2:_(s1) = G_ICMP intpred(ne), %0, %1
    %3:_(s32) = G_SEXT %2
    $vgpr0 = COPY %3
...

---
name: test_icmp_v2p3
body: |
  bb.0.entry:
    liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
    ; CHECK-LABEL: name: test_icmp_v2p3
    ; CHECK: [[COPY:%[0-9]+]]:_(<2 x p3>) = COPY $vgpr0_vgpr1
    ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x p3>) = COPY $vgpr0_vgpr1
    ; CHECK: [[UV:%[0-9]+]]:_(p3), [[UV1:%[0-9]+]]:_(p3) = G_UNMERGE_VALUES [[COPY]](<2 x p3>)
    ; CHECK: [[UV2:%[0-9]+]]:_(p3), [[UV3:%[0-9]+]]:_(p3) = G_UNMERGE_VALUES [[COPY1]](<2 x p3>)
    ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[UV]](p3), [[UV2]]
    ; CHECK: [[ICMP1:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[UV1]](p3), [[UV3]]
    ; CHECK: [[SEXT:%[0-9]+]]:_(s32) = G_SEXT [[ICMP]](s1)
    ; CHECK: [[SEXT1:%[0-9]+]]:_(s32) = G_SEXT [[ICMP1]](s1)
    ; CHECK: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[SEXT]](s32), [[SEXT1]](s32)
    ; CHECK: $vgpr0_vgpr1 = COPY [[BUILD_VECTOR]](<2 x s32>)
    %0:_(<2 x p3>) = COPY $vgpr0_vgpr1
    %1:_(<2 x p3>) = COPY $vgpr0_vgpr1
    %2:_(<2 x s1>) = G_ICMP intpred(ne), %0, %1
    %3:_(<2 x s32>) = G_SEXT %2
    $vgpr0_vgpr1 = COPY %3
...

---
name: test_icmp_v2p999
body: |
  bb.0.entry:
    liveins: $vgpr0_vgpr1_vgpr2_vgpr3, $vgpr4_vgpr5_vgpr6_vgpr7
    ; CHECK-LABEL: name: test_icmp_v2p999
    ; CHECK: [[COPY:%[0-9]+]]:_(<2 x p999>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
    ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x p999>) = COPY $vgpr4_vgpr5_vgpr6_vgpr7
    ; CHECK: [[UV:%[0-9]+]]:_(p999), [[UV1:%[0-9]+]]:_(p999) = G_UNMERGE_VALUES [[COPY]](<2 x p999>)
    ; CHECK: [[UV2:%[0-9]+]]:_(p999), [[UV3:%[0-9]+]]:_(p999) = G_UNMERGE_VALUES [[COPY1]](<2 x p999>)
    ; CHECK: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[UV]](p999), [[UV2]]
    ; CHECK: [[ICMP1:%[0-9]+]]:_(s1) = G_ICMP intpred(ne), [[UV1]](p999), [[UV3]]
    ; CHECK: [[SEXT:%[0-9]+]]:_(s32) = G_SEXT [[ICMP]](s1)
    ; CHECK: [[SEXT1:%[0-9]+]]:_(s32) = G_SEXT [[ICMP1]](s1)
    ; CHECK: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[SEXT]](s32), [[SEXT1]](s32)
    ; CHECK: $vgpr0_vgpr1 = COPY [[BUILD_VECTOR]](<2 x s32>)
    %0:_(<2 x p999>) = COPY $vgpr0_vgpr1_vgpr2_vgpr3
    %1:_(<2 x p999>) = COPY $vgpr4_vgpr5_vgpr6_vgpr7
    %2:_(<2 x s1>) = G_ICMP intpred(ne), %0, %1
    %3:_(<2 x s32>) = G_SEXT %2
    $vgpr0_vgpr1 = COPY %3
...