# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple=amdgcn -run-pass=amdgpu-prelegalizer-combiner -verify-machineinstrs %s -o - | FileCheck %s
---
name: test_const_const
tracksRegLiveness: true
body: |
bb.0:
; CHECK-LABEL: name: test_const_const
; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 15
; CHECK-NEXT: $sgpr0 = COPY [[C]](s32)
; CHECK-NEXT: SI_RETURN_TO_EPILOG implicit $sgpr0
%0:_(s32) = G_CONSTANT i32 15
%1:_(s32) = G_CONSTANT i32 255
%2:_(s32) = G_AND %0(s32), %1(s32)
$sgpr0 = COPY %2(s32)
SI_RETURN_TO_EPILOG implicit $sgpr0
...
---
name: test_const_const_2
tracksRegLiveness: true
body: |
bb.0:
; CHECK-LABEL: name: test_const_const_2
; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 15
; CHECK-NEXT: $sgpr0 = COPY [[C]](s32)
; CHECK-NEXT: SI_RETURN_TO_EPILOG implicit $sgpr0
%0:_(s32) = G_CONSTANT i32 255
%1:_(s32) = G_CONSTANT i32 15
%2:_(s32) = G_AND %0(s32), %1(s32)
$sgpr0 = COPY %2(s32)
SI_RETURN_TO_EPILOG implicit $sgpr0
...
---
name: test_const_const_3
tracksRegLiveness: true
body: |
bb.0:
; CHECK-LABEL: name: test_const_const_3
; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1431655766
; CHECK-NEXT: $vgpr0 = COPY [[C]](s32)
; CHECK-NEXT: SI_RETURN_TO_EPILOG implicit $vgpr0
%0:_(s32) = G_CONSTANT i32 2863311530
%1:_(s32) = G_CONSTANT i32 4008636142
%2:_(s32) = G_AND %0(s32), %1(s32)
$vgpr0 = COPY %2(s32)
SI_RETURN_TO_EPILOG implicit $vgpr0
...
---
name: test_and_and
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0
; CHECK-LABEL: name: test_and_and
; CHECK: liveins: $vgpr0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 15
; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY]], [[C]]
; CHECK-NEXT: $vgpr0 = COPY [[AND]](s32)
; CHECK-NEXT: SI_RETURN_TO_EPILOG implicit $vgpr0
%0:_(s32) = COPY $vgpr0
%1:_(s32) = G_CONSTANT i32 15
%2:_(s32) = G_CONSTANT i32 255
%3:_(s32) = G_AND %0, %1(s32)
%4:_(s32) = G_AND %3, %2
$vgpr0 = COPY %4(s32)
SI_RETURN_TO_EPILOG implicit $vgpr0
...
---
name: test_shl_and
tracksRegLiveness: true
body: |
bb.0:
liveins: $sgpr0
; CHECK-LABEL: name: test_shl_and
; CHECK: liveins: $sgpr0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $sgpr0
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 5
; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[COPY]], [[C]](s32)
; CHECK-NEXT: $sgpr0 = COPY [[SHL]](s32)
; CHECK-NEXT: SI_RETURN_TO_EPILOG implicit $sgpr0
%0:_(s32) = COPY $sgpr0
%1:_(s32) = G_CONSTANT i32 5
%2:_(s32) = G_CONSTANT i32 4294967264
%3:_(s32) = G_SHL %0, %1(s32)
%4:_(s32) = G_AND %3, %2
$sgpr0 = COPY %4(s32)
SI_RETURN_TO_EPILOG implicit $sgpr0
...
---
name: test_lshr_and
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0
; CHECK-LABEL: name: test_lshr_and
; CHECK: liveins: $vgpr0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 5
; CHECK-NEXT: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[COPY]], [[C]](s32)
; CHECK-NEXT: $vgpr0 = COPY [[LSHR]](s32)
; CHECK-NEXT: SI_RETURN_TO_EPILOG implicit $vgpr0
%0:_(s32) = COPY $vgpr0
%1:_(s32) = G_CONSTANT i32 5
%2:_(s32) = G_CONSTANT i32 134217727
%3:_(s32) = G_LSHR %0, %1(s32)
%4:_(s32) = G_AND %3, %2
$vgpr0 = COPY %4(s32)
SI_RETURN_TO_EPILOG implicit $vgpr0
...
---
name: test_and_non_const
tracksRegLiveness: true
body: |
bb.0:
liveins: $sgpr0, $sgpr1
; CHECK-LABEL: name: test_and_non_const
; CHECK: liveins: $sgpr0, $sgpr1
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $sgpr0
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 16
; CHECK-NEXT: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[COPY]], [[C]](s32)
; CHECK-NEXT: $sgpr0 = COPY [[LSHR]](s32)
; CHECK-NEXT: SI_RETURN_TO_EPILOG implicit $sgpr0
%0:_(s32) = COPY $sgpr0
%1:_(s32) = COPY $sgpr1
%2:_(s32) = G_CONSTANT i32 16
%3:_(s32) = G_CONSTANT i32 65535
%4:_(s32) = G_OR %1, %3
%5:_(s32) = G_LSHR %0, %2(s32)
%6:_(s32) = G_AND %5, %4
$sgpr0 = COPY %6(s32)
SI_RETURN_TO_EPILOG implicit $sgpr0
...
---
name: test_sext_inreg
tracksRegLiveness: true
body: |
bb.0:
; CHECK-LABEL: name: test_sext_inreg
; CHECK: %cst_1:_(s32) = G_CONSTANT i32 -5
; CHECK-NEXT: $sgpr0 = COPY %cst_1(s32)
; CHECK-NEXT: SI_RETURN_TO_EPILOG implicit $sgpr0
%cst_1:_(s32) = G_CONSTANT i32 -5
; 000 ... 1011
%cst_11:_(s32) = G_CONSTANT i32 11
; Sext from the 4th bit -> 111 ... 1011 = -5
%sext_inreg_11:_(s32) = G_SEXT_INREG %cst_11, 4
%and:_(s32) = G_AND %cst_1(s32), %sext_inreg_11(s32)
$sgpr0 = COPY %and(s32)
SI_RETURN_TO_EPILOG implicit $sgpr0
...
---
name: vector_const_splat_const_splat
tracksRegLiveness: true
body: |
bb.0:
; CHECK-LABEL: name: vector_const_splat_const_splat
; CHECK: %fifteen:_(s16) = G_CONSTANT i16 15
; CHECK-NEXT: %c1:_(<2 x s16>) = G_BUILD_VECTOR %fifteen(s16), %fifteen(s16)
; CHECK-NEXT: $vgpr0 = COPY %c1(<2 x s16>)
; CHECK-NEXT: SI_RETURN_TO_EPILOG implicit $vgpr0
%fifteen:_(s16) = G_CONSTANT i16 15
%mask:_(s16) = G_CONSTANT i16 255
%c1:_(<2 x s16>) = G_BUILD_VECTOR %fifteen, %fifteen
%c2:_(<2 x s16>) = G_BUILD_VECTOR %mask, %mask
%and:_(<2 x s16>) = G_AND %c1(<2 x s16>), %c2(<2 x s16>)
$vgpr0 = COPY %and(<2 x s16>)
SI_RETURN_TO_EPILOG implicit $vgpr0
...
---
name: vector_const_valid_not_splat
tracksRegLiveness: true
body: |
bb.0:
; CHECK-LABEL: name: vector_const_valid_not_splat
; CHECK: %fifteen:_(s16) = G_CONSTANT i16 15
; CHECK-NEXT: %sixteen:_(s16) = G_CONSTANT i16 16
; CHECK-NEXT: %c1:_(<2 x s16>) = G_BUILD_VECTOR %fifteen(s16), %sixteen(s16)
; CHECK-NEXT: $vgpr0 = COPY %c1(<2 x s16>)
; CHECK-NEXT: SI_RETURN_TO_EPILOG implicit $vgpr0
%fifteen:_(s16) = G_CONSTANT i16 15
%sixteen:_(s16) = G_CONSTANT i16 16
%mask:_(s16) = G_CONSTANT i16 255
%c1:_(<2 x s16>) = G_BUILD_VECTOR %fifteen, %sixteen
%c2:_(<2 x s16>) = G_BUILD_VECTOR %mask, %mask
%and:_(<2 x s16>) = G_AND %c1(<2 x s16>), %c2(<2 x s16>)
$vgpr0 = COPY %and(<2 x s16>)
SI_RETURN_TO_EPILOG implicit $vgpr0
...
---
name: vector_dont_combine_const_too_wide
tracksRegLiveness: true
body: |
bb.0:
; CHECK-LABEL: name: vector_dont_combine_const_too_wide
; CHECK: %fifteen:_(s16) = G_CONSTANT i16 15
; CHECK-NEXT: %too_wide:_(s16) = G_CONSTANT i16 257
; CHECK-NEXT: %mask:_(s16) = G_CONSTANT i16 255
; CHECK-NEXT: %c1:_(<2 x s16>) = G_BUILD_VECTOR %fifteen(s16), %too_wide(s16)
; CHECK-NEXT: %c2:_(<2 x s16>) = G_BUILD_VECTOR %mask(s16), %mask(s16)
; CHECK-NEXT: %and:_(<2 x s16>) = G_AND %c1, %c2
; CHECK-NEXT: $vgpr0 = COPY %and(<2 x s16>)
; CHECK-NEXT: SI_RETURN_TO_EPILOG implicit $vgpr0
%fifteen:_(s16) = G_CONSTANT i16 15
%too_wide:_(s16) = G_CONSTANT i16 257
%mask:_(s16) = G_CONSTANT i16 255
%c1:_(<2 x s16>) = G_BUILD_VECTOR %fifteen, %too_wide
%c2:_(<2 x s16>) = G_BUILD_VECTOR %mask, %mask
%and:_(<2 x s16>) = G_AND %c1(<2 x s16>), %c2(<2 x s16>)
$vgpr0 = COPY %and(<2 x s16>)
SI_RETURN_TO_EPILOG implicit $vgpr0
...