# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=tahiti -run-pass=amdgpu-prelegalizer-combiner -verify-machineinstrs %s -o - | FileCheck -check-prefix=GCN %s
---
name: sext_inreg_s32_7_sextload_from_1
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
; GCN-LABEL: name: sext_inreg_s32_7_sextload_from_1
; GCN: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
; GCN-NEXT: {{ $}}
; GCN-NEXT: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
; GCN-NEXT: [[SEXTLOAD:%[0-9]+]]:_(s32) = G_SEXTLOAD [[COPY]](p1) :: (load (s8), addrspace 1)
; GCN-NEXT: [[SEXT_INREG:%[0-9]+]]:_(s32) = G_SEXT_INREG [[SEXTLOAD]], 7
; GCN-NEXT: $vgpr0 = COPY [[SEXT_INREG]](s32)
%0:_(p1) = COPY $vgpr0_vgpr1
%1:_(s32) = G_SEXTLOAD %0 :: (load (s8), addrspace 1)
%2:_(s32) = G_SEXT_INREG %1, 7
$vgpr0 = COPY %2
...
---
name: sext_inreg_s32_8_sextload_from_1
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
; GCN-LABEL: name: sext_inreg_s32_8_sextload_from_1
; GCN: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
; GCN-NEXT: {{ $}}
; GCN-NEXT: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
; GCN-NEXT: [[SEXTLOAD:%[0-9]+]]:_(s32) = G_SEXTLOAD [[COPY]](p1) :: (load (s8), addrspace 1)
; GCN-NEXT: $vgpr0 = COPY [[SEXTLOAD]](s32)
%0:_(p1) = COPY $vgpr0_vgpr1
%1:_(s32) = G_SEXTLOAD %0 :: (load (s8), addrspace 1)
%2:_(s32) = G_SEXT_INREG %1, 8
$vgpr0 = COPY %2
...
---
name: sext_inreg_s32_9_sextload_from_1
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
; GCN-LABEL: name: sext_inreg_s32_9_sextload_from_1
; GCN: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
; GCN-NEXT: {{ $}}
; GCN-NEXT: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
; GCN-NEXT: [[SEXTLOAD:%[0-9]+]]:_(s32) = G_SEXTLOAD [[COPY]](p1) :: (load (s8), addrspace 1)
; GCN-NEXT: $vgpr0 = COPY [[SEXTLOAD]](s32)
%0:_(p1) = COPY $vgpr0_vgpr1
%1:_(s32) = G_SEXTLOAD %0 :: (load (s8), addrspace 1)
%2:_(s32) = G_SEXT_INREG %1, 9
$vgpr0 = COPY %2
...
---
name: sext_inreg_s32_7_sext_from_s8
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
; GCN-LABEL: name: sext_inreg_s32_7_sext_from_s8
; GCN: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
; GCN-NEXT: {{ $}}
; GCN-NEXT: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
; GCN-NEXT: [[SEXTLOAD:%[0-9]+]]:_(s32) = G_SEXTLOAD [[COPY]](p1) :: (load (s8), addrspace 1)
; GCN-NEXT: [[SEXT_INREG:%[0-9]+]]:_(s32) = G_SEXT_INREG [[SEXTLOAD]], 7
; GCN-NEXT: $vgpr0 = COPY [[SEXT_INREG]](s32)
%0:_(p1) = COPY $vgpr0_vgpr1
%1:_(s8) = G_LOAD %0 :: (load (s8), addrspace 1)
%2:_(s32) = G_SEXT %1
%3:_(s32) = G_SEXT_INREG %2, 7
$vgpr0 = COPY %3
...
---
name: sext_inreg_s32_8_sext_from_s8
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
; GCN-LABEL: name: sext_inreg_s32_8_sext_from_s8
; GCN: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
; GCN-NEXT: {{ $}}
; GCN-NEXT: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
; GCN-NEXT: [[SEXTLOAD:%[0-9]+]]:_(s32) = G_SEXTLOAD [[COPY]](p1) :: (load (s8), addrspace 1)
; GCN-NEXT: $vgpr0 = COPY [[SEXTLOAD]](s32)
%0:_(p1) = COPY $vgpr0_vgpr1
%1:_(s8) = G_LOAD %0 :: (load (s8), addrspace 1)
%2:_(s32) = G_SEXT %1
%3:_(s32) = G_SEXT_INREG %2, 8
$vgpr0 = COPY %3
...
---
name: sext_inreg_s32_8_sext_from_s9
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
; GCN-LABEL: name: sext_inreg_s32_8_sext_from_s9
; GCN: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
; GCN-NEXT: {{ $}}
; GCN-NEXT: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
; GCN-NEXT: [[SEXTLOAD:%[0-9]+]]:_(s32) = G_SEXTLOAD [[COPY]](p1) :: (load (s8), addrspace 1)
; GCN-NEXT: $vgpr0 = COPY [[SEXTLOAD]](s32)
%0:_(p1) = COPY $vgpr0_vgpr1
%1:_(s8) = G_LOAD %0 :: (load (s8), addrspace 1)
%2:_(s32) = G_SEXT %1
%3:_(s32) = G_SEXT_INREG %2, 9
$vgpr0 = COPY %3
...
---
name: sext_inreg_v2s32_7_sext_from_v2s8
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
; GCN-LABEL: name: sext_inreg_v2s32_7_sext_from_v2s8
; GCN: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
; GCN-NEXT: {{ $}}
; GCN-NEXT: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
; GCN-NEXT: [[LOAD:%[0-9]+]]:_(<2 x s8>) = G_LOAD [[COPY]](p1) :: (load (<2 x s8>), addrspace 1)
; GCN-NEXT: [[SEXT:%[0-9]+]]:_(<2 x s32>) = G_SEXT [[LOAD]](<2 x s8>)
; GCN-NEXT: [[SEXT_INREG:%[0-9]+]]:_(<2 x s32>) = G_SEXT_INREG [[SEXT]], 7
; GCN-NEXT: $vgpr0_vgpr1 = COPY [[SEXT_INREG]](<2 x s32>)
%0:_(p1) = COPY $vgpr0_vgpr1
%1:_(<2 x s8>) = G_LOAD %0 :: (load (<2 x s8>), addrspace 1)
%2:_(<2 x s32>) = G_SEXT %1
%3:_(<2 x s32>) = G_SEXT_INREG %2, 7
$vgpr0_vgpr1 = COPY %3
...
---
name: sext_inreg_v2s32_8_sext_from_v2s8
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
; GCN-LABEL: name: sext_inreg_v2s32_8_sext_from_v2s8
; GCN: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
; GCN-NEXT: {{ $}}
; GCN-NEXT: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
; GCN-NEXT: [[LOAD:%[0-9]+]]:_(<2 x s8>) = G_LOAD [[COPY]](p1) :: (load (<2 x s8>), addrspace 1)
; GCN-NEXT: [[SEXT:%[0-9]+]]:_(<2 x s32>) = G_SEXT [[LOAD]](<2 x s8>)
; GCN-NEXT: $vgpr0_vgpr1 = COPY [[SEXT]](<2 x s32>)
%0:_(p1) = COPY $vgpr0_vgpr1
%1:_(<2 x s8>) = G_LOAD %0 :: (load (<2 x s8>), addrspace 1)
%2:_(<2 x s32>) = G_SEXT %1
%3:_(<2 x s32>) = G_SEXT_INREG %2, 8
$vgpr0_vgpr1 = COPY %3
...
---
name: sext_inreg_v2s32_9_sext_from_v2s8
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
; GCN-LABEL: name: sext_inreg_v2s32_9_sext_from_v2s8
; GCN: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
; GCN-NEXT: {{ $}}
; GCN-NEXT: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
; GCN-NEXT: [[LOAD:%[0-9]+]]:_(<2 x s8>) = G_LOAD [[COPY]](p1) :: (load (<2 x s8>), addrspace 1)
; GCN-NEXT: [[SEXT:%[0-9]+]]:_(<2 x s32>) = G_SEXT [[LOAD]](<2 x s8>)
; GCN-NEXT: $vgpr0_vgpr1 = COPY [[SEXT]](<2 x s32>)
%0:_(p1) = COPY $vgpr0_vgpr1
%1:_(<2 x s8>) = G_LOAD %0 :: (load (<2 x s8>), addrspace 1)
%2:_(<2 x s32>) = G_SEXT %1
%3:_(<2 x s32>) = G_SEXT_INREG %2, 9
$vgpr0_vgpr1 = COPY %3
...
---
name: sext_inreg_s32_7_zextload_from_1
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
; GCN-LABEL: name: sext_inreg_s32_7_zextload_from_1
; GCN: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
; GCN-NEXT: {{ $}}
; GCN-NEXT: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
; GCN-NEXT: [[ZEXTLOAD:%[0-9]+]]:_(s32) = G_ZEXTLOAD [[COPY]](p1) :: (load (s8), addrspace 1)
; GCN-NEXT: [[SEXT_INREG:%[0-9]+]]:_(s32) = G_SEXT_INREG [[ZEXTLOAD]], 7
; GCN-NEXT: $vgpr0 = COPY [[SEXT_INREG]](s32)
%0:_(p1) = COPY $vgpr0_vgpr1
%1:_(s32) = G_ZEXTLOAD %0 :: (load (s8), addrspace 1)
%2:_(s32) = G_SEXT_INREG %1, 7
$vgpr0 = COPY %2
...
---
name: sext_inreg_s32_8_zextload_from_1
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
; GCN-LABEL: name: sext_inreg_s32_8_zextload_from_1
; GCN: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
; GCN-NEXT: {{ $}}
; GCN-NEXT: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
; GCN-NEXT: [[ZEXTLOAD:%[0-9]+]]:_(s32) = G_ZEXTLOAD [[COPY]](p1) :: (load (s8), addrspace 1)
; GCN-NEXT: [[SEXT_INREG:%[0-9]+]]:_(s32) = G_SEXT_INREG [[ZEXTLOAD]], 8
; GCN-NEXT: $vgpr0 = COPY [[SEXT_INREG]](s32)
%0:_(p1) = COPY $vgpr0_vgpr1
%1:_(s32) = G_ZEXTLOAD %0 :: (load (s8), addrspace 1)
%2:_(s32) = G_SEXT_INREG %1, 8
$vgpr0 = COPY %2
...
---
name: sext_inreg_s32_9_zextload_from_1
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
; GCN-LABEL: name: sext_inreg_s32_9_zextload_from_1
; GCN: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
; GCN-NEXT: {{ $}}
; GCN-NEXT: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
; GCN-NEXT: [[ZEXTLOAD:%[0-9]+]]:_(s32) = G_ZEXTLOAD [[COPY]](p1) :: (load (s8), addrspace 1)
; GCN-NEXT: $vgpr0 = COPY [[ZEXTLOAD]](s32)
%0:_(p1) = COPY $vgpr0_vgpr1
%1:_(s32) = G_ZEXTLOAD %0 :: (load (s8), addrspace 1)
%2:_(s32) = G_SEXT_INREG %1, 9
$vgpr0 = COPY %2
...
---
name: sext_inreg_s32_select_sextload_from_1
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4, $vgpr5
; GCN-LABEL: name: sext_inreg_s32_select_sextload_from_1
; GCN: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4, $vgpr5
; GCN-NEXT: {{ $}}
; GCN-NEXT: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
; GCN-NEXT: [[COPY1:%[0-9]+]]:_(p1) = COPY $vgpr2_vgpr3
; GCN-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $vgpr4
; GCN-NEXT: [[COPY3:%[0-9]+]]:_(s32) = COPY $vgpr5
; GCN-NEXT: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[COPY2]](s32), [[COPY3]]
; GCN-NEXT: [[SEXTLOAD:%[0-9]+]]:_(s32) = G_SEXTLOAD [[COPY]](p1) :: (load (s8), addrspace 1)
; GCN-NEXT: [[SEXTLOAD1:%[0-9]+]]:_(s32) = G_SEXTLOAD [[COPY1]](p1) :: (load (s8), addrspace 1)
; GCN-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[ICMP]](s1), [[SEXTLOAD]], [[SEXTLOAD1]]
; GCN-NEXT: $vgpr0 = COPY [[SELECT]](s32)
%0:_(p1) = COPY $vgpr0_vgpr1
%1:_(p1) = COPY $vgpr2_vgpr3
%2:_(s32) = COPY $vgpr4
%3:_(s32) = COPY $vgpr5
%4:_(s1) = G_ICMP intpred(eq), %2, %3
%5:_(s32) = G_SEXTLOAD %0 :: (load (s8), addrspace 1)
%6:_(s32) = G_SEXTLOAD %1 :: (load (s8), addrspace 1)
%7:_(s32) = G_SELECT %4, %5, %6
%8:_(s32) = G_SEXT_INREG %7, 8
$vgpr0 = COPY %8
...
---
name: sext_inreg_s32_select_sextload_from_1_fail_lhs
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4, $vgpr5
; GCN-LABEL: name: sext_inreg_s32_select_sextload_from_1_fail_lhs
; GCN: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4, $vgpr5
; GCN-NEXT: {{ $}}
; GCN-NEXT: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
; GCN-NEXT: [[COPY1:%[0-9]+]]:_(p1) = COPY $vgpr2_vgpr3
; GCN-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $vgpr4
; GCN-NEXT: [[COPY3:%[0-9]+]]:_(s32) = COPY $vgpr5
; GCN-NEXT: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[COPY2]](s32), [[COPY3]]
; GCN-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p1) :: (load (s32), addrspace 1)
; GCN-NEXT: [[SEXTLOAD:%[0-9]+]]:_(s32) = G_SEXTLOAD [[COPY1]](p1) :: (load (s8), addrspace 1)
; GCN-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[ICMP]](s1), [[LOAD]], [[SEXTLOAD]]
; GCN-NEXT: [[SEXT_INREG:%[0-9]+]]:_(s32) = G_SEXT_INREG [[SELECT]], 8
; GCN-NEXT: $vgpr0 = COPY [[SEXT_INREG]](s32)
%0:_(p1) = COPY $vgpr0_vgpr1
%1:_(p1) = COPY $vgpr2_vgpr3
%2:_(s32) = COPY $vgpr4
%3:_(s32) = COPY $vgpr5
%4:_(s1) = G_ICMP intpred(eq), %2, %3
%5:_(s32) = G_LOAD %0 :: (load (s32), addrspace 1)
%6:_(s32) = G_SEXTLOAD %1 :: (load (s8), addrspace 1)
%7:_(s32) = G_SELECT %4, %5, %6
%8:_(s32) = G_SEXT_INREG %7, 8
$vgpr0 = COPY %8
...
---
name: sext_inreg_s32_select_sextload_from_1_fail_rhs
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4, $vgpr5
; GCN-LABEL: name: sext_inreg_s32_select_sextload_from_1_fail_rhs
; GCN: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4, $vgpr5
; GCN-NEXT: {{ $}}
; GCN-NEXT: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
; GCN-NEXT: [[COPY1:%[0-9]+]]:_(p1) = COPY $vgpr2_vgpr3
; GCN-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $vgpr4
; GCN-NEXT: [[COPY3:%[0-9]+]]:_(s32) = COPY $vgpr5
; GCN-NEXT: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[COPY2]](s32), [[COPY3]]
; GCN-NEXT: [[SEXTLOAD:%[0-9]+]]:_(s32) = G_SEXTLOAD [[COPY]](p1) :: (load (s8), addrspace 1)
; GCN-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY1]](p1) :: (load (s32), addrspace 1)
; GCN-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[ICMP]](s1), [[SEXTLOAD]], [[LOAD]]
; GCN-NEXT: [[SEXT_INREG:%[0-9]+]]:_(s32) = G_SEXT_INREG [[SELECT]], 8
; GCN-NEXT: $vgpr0 = COPY [[SEXT_INREG]](s32)
%0:_(p1) = COPY $vgpr0_vgpr1
%1:_(p1) = COPY $vgpr2_vgpr3
%2:_(s32) = COPY $vgpr4
%3:_(s32) = COPY $vgpr5
%4:_(s1) = G_ICMP intpred(eq), %2, %3
%5:_(s32) = G_SEXTLOAD %0 :: (load (s8), addrspace 1)
%6:_(s32) = G_LOAD %1 :: (load (s32), addrspace 1)
%7:_(s32) = G_SELECT %4, %5, %6
%8:_(s32) = G_SEXT_INREG %7, 8
$vgpr0 = COPY %8
...
---
name: assert_sext_s8
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0
; GCN-LABEL: name: assert_sext_s8
; GCN: liveins: $vgpr0
; GCN-NEXT: {{ $}}
; GCN-NEXT: %copy:_(s32) = COPY $vgpr0
; GCN-NEXT: %assert_sext:_(s32) = G_ASSERT_SEXT %copy, 8
; GCN-NEXT: $vgpr0 = COPY %assert_sext(s32)
%copy:_(s32) = COPY $vgpr0
%assert_sext:_(s32) = G_ASSERT_SEXT %copy, 8
%sext_inreg:_(s32) = G_SEXT_INREG %assert_sext, 8
$vgpr0 = COPY %sext_inreg
...
---
name: sext_inreg_s7_assert_sext_s8
tracksRegLiveness: true
body: |
bb.0:
liveins: $vgpr0
; GCN-LABEL: name: sext_inreg_s7_assert_sext_s8
; GCN: liveins: $vgpr0
; GCN-NEXT: {{ $}}
; GCN-NEXT: %copy:_(s32) = COPY $vgpr0
; GCN-NEXT: %assert_sext:_(s32) = G_ASSERT_SEXT %copy, 8
; GCN-NEXT: %sext_inreg:_(s32) = G_SEXT_INREG %assert_sext, 7
; GCN-NEXT: $vgpr0 = COPY %sext_inreg(s32)
%copy:_(s32) = COPY $vgpr0
%assert_sext:_(s32) = G_ASSERT_SEXT %copy, 8
%sext_inreg:_(s32) = G_SEXT_INREG %assert_sext, 7
$vgpr0 = COPY %sext_inreg
...