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

Tree @stable (Download .tar.gz)

legalize-merge-values.mir @stableraw · history · blame

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

---
name: test_merge_s16_s8_s8
body: |
  bb.0:
    ; CHECK-LABEL: name: test_merge_s16_s8_s8
    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
    ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
    ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 8
    ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY [[C2]](s32)
    ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C3]]
    ; CHECK: [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
    ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[C1]](s32)
    ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C4]]
    ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[AND1]], [[AND]](s32)
    ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY [[C]](s32)
    ; CHECK: [[AND2:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C4]]
    ; CHECK: [[COPY3:%[0-9]+]]:_(s32) = COPY [[SHL]](s32)
    ; CHECK: [[OR:%[0-9]+]]:_(s32) = G_OR [[AND2]], [[COPY3]]
    ; CHECK: [[COPY4:%[0-9]+]]:_(s32) = COPY [[OR]](s32)
    ; CHECK: $vgpr0 = COPY [[COPY4]](s32)
    %0:_(s8) = G_CONSTANT i8 0
    %1:_(s8) = G_CONSTANT i8 1
    %2:_(s16) = G_MERGE_VALUES %0, %1
    %3:_(s32) = G_ANYEXT %2
    $vgpr0 = COPY %3
...

---
name: test_merge_s24_s8_s8_s8
body: |
  bb.0:
    ; CHECK-LABEL: name: test_merge_s24_s8_s8_s8
    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
    ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
    ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 2
    ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 8
    ; CHECK: [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 16777215
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY [[C3]](s32)
    ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C4]]
    ; CHECK: [[C5:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
    ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[C1]](s32)
    ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C5]]
    ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[AND1]], [[AND]](s32)
    ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY [[C]](s32)
    ; CHECK: [[AND2:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C5]]
    ; CHECK: [[COPY3:%[0-9]+]]:_(s32) = COPY [[SHL]](s32)
    ; CHECK: [[OR:%[0-9]+]]:_(s32) = G_OR [[AND2]], [[COPY3]]
    ; CHECK: [[C6:%[0-9]+]]:_(s32) = G_CONSTANT i32 16
    ; CHECK: [[COPY4:%[0-9]+]]:_(s32) = COPY [[C6]](s32)
    ; CHECK: [[AND3:%[0-9]+]]:_(s32) = G_AND [[COPY4]], [[C4]]
    ; CHECK: [[COPY5:%[0-9]+]]:_(s32) = COPY [[C2]](s32)
    ; CHECK: [[AND4:%[0-9]+]]:_(s32) = G_AND [[COPY5]], [[C5]]
    ; CHECK: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[AND4]], [[AND3]](s32)
    ; CHECK: [[COPY6:%[0-9]+]]:_(s32) = COPY [[OR]](s32)
    ; CHECK: [[COPY7:%[0-9]+]]:_(s32) = COPY [[SHL1]](s32)
    ; CHECK: [[OR1:%[0-9]+]]:_(s32) = G_OR [[COPY6]], [[COPY7]]
    ; CHECK: [[COPY8:%[0-9]+]]:_(s32) = COPY [[OR1]](s32)
    ; CHECK: $vgpr0 = COPY [[COPY8]](s32)
    %0:_(s8) = G_CONSTANT i8 0
    %1:_(s8) = G_CONSTANT i8 1
    %2:_(s8) = G_CONSTANT i8 2
    %3:_(s24) = G_MERGE_VALUES %0, %1, %2
    %4:_(s32) = G_ANYEXT %3
    $vgpr0 = COPY %4
...

---
name: test_merge_s32_s8_s8_s8_s8
body: |
  bb.0:
    ; CHECK-LABEL: name: test_merge_s32_s8_s8_s8_s8
    ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
    ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
    ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 2
    ; CHECK: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 3
    ; CHECK: [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY [[C]](s32)
    ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C4]]
    ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY [[C1]](s32)
    ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C4]]
    ; CHECK: [[C5:%[0-9]+]]:_(s32) = G_CONSTANT i32 8
    ; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[AND1]], [[C5]](s32)
    ; CHECK: [[OR:%[0-9]+]]:_(s32) = G_OR [[AND]], [[SHL]]
    ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY [[C2]](s32)
    ; CHECK: [[AND2:%[0-9]+]]:_(s32) = G_AND [[COPY2]], [[C4]]
    ; CHECK: [[C6:%[0-9]+]]:_(s32) = G_CONSTANT i32 16
    ; CHECK: [[SHL1:%[0-9]+]]:_(s32) = G_SHL [[AND2]], [[C6]](s32)
    ; CHECK: [[OR1:%[0-9]+]]:_(s32) = G_OR [[OR]], [[SHL1]]
    ; CHECK: [[COPY3:%[0-9]+]]:_(s32) = COPY [[C3]](s32)
    ; CHECK: [[AND3:%[0-9]+]]:_(s32) = G_AND [[COPY3]], [[C4]]
    ; CHECK: [[C7:%[0-9]+]]:_(s32) = G_CONSTANT i32 24
    ; CHECK: [[SHL2:%[0-9]+]]:_(s32) = G_SHL [[AND3]], [[C7]](s32)
    ; CHECK: [[OR2:%[0-9]+]]:_(s32) = G_OR [[OR1]], [[SHL2]]
    ; CHECK: $vgpr0 = COPY [[OR2]](s32)
    %0:_(s8) = G_CONSTANT i8 0
    %1:_(s8) = G_CONSTANT i8 1
    %2:_(s8) = G_CONSTANT i8 2
    %3:_(s8) = G_CONSTANT i8 3
    %4:_(s32) = G_MERGE_VALUES %0, %1, %2, %3
    $vgpr0 = COPY %4
...

---
name: test_merge_s64_s32_s32
body: |
  bb.0:
    liveins: $vgpr0, $vgpr1
    ; CHECK-LABEL: name: test_merge_s64_s32_s32
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
    ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1
    ; CHECK: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[COPY]](s32), [[COPY1]](s32)
    ; CHECK: $vgpr1_vgpr2 = COPY [[MV]](s64)
    %0:_(s32) = COPY $vgpr0
    %1:_(s32) = COPY $vgpr1
    %2:_(s64) = G_MERGE_VALUES %0, %1
    $vgpr1_vgpr2 = COPY %2
...

---
name: test_merge_s64_s16_s16_s16_s16
body: |
  bb.0:
    liveins: $vgpr0, $vgpr1, $vgpr2, $vgpr3
    ; CHECK-LABEL: name: test_merge_s64_s16_s16_s16_s16
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
    ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1
    ; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY $vgpr2
    ; CHECK: [[COPY3:%[0-9]+]]:_(s32) = COPY $vgpr3
    ; CHECK: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s32)
    ; CHECK: [[TRUNC1:%[0-9]+]]:_(s16) = G_TRUNC [[COPY1]](s32)
    ; CHECK: [[TRUNC2:%[0-9]+]]:_(s16) = G_TRUNC [[COPY2]](s32)
    ; CHECK: [[TRUNC3:%[0-9]+]]:_(s16) = G_TRUNC [[COPY3]](s32)
    ; CHECK: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[TRUNC]](s16), [[TRUNC1]](s16), [[TRUNC2]](s16), [[TRUNC3]](s16)
    ; CHECK: $vgpr1_vgpr2 = COPY [[MV]](s64)
    %0:_(s32) = COPY $vgpr0
    %1:_(s32) = COPY $vgpr1
    %2:_(s32) = COPY $vgpr2
    %3:_(s32) = COPY $vgpr3
    %4:_(s16) = G_TRUNC %0
    %5:_(s16) = G_TRUNC %1
    %6:_(s16) = G_TRUNC %2
    %7:_(s16) = G_TRUNC %3
    %8:_(s64) = G_MERGE_VALUES %4, %5, %6, %7
    $vgpr1_vgpr2 = COPY %8
...