# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -o - -mtriple=aarch64-unknown-unknown -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs %s | FileCheck %s
---
name: test_combine_anyext_trunc
body: |
bb.1:
liveins: $x0
; CHECK-LABEL: name: test_combine_anyext_trunc
; CHECK: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
; CHECK-NEXT: $x1 = COPY [[COPY]](s64)
%0:_(s64) = COPY $x0
%1:_(s32) = G_TRUNC %0(s64)
%2:_(s64) = G_ANYEXT %1(s32)
$x1 = COPY %2(s64)
...
---
name: test_combine_anyext_trunc_with_hint
body: |
bb.1:
liveins: $x0
; CHECK-LABEL: name: test_combine_anyext_trunc_with_hint
; CHECK: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
; CHECK-NEXT: $x1 = COPY [[COPY]](s64)
%0:_(s64) = COPY $x0
%1:_(s32) = G_TRUNC %0(s64)
%2:_(s32) = G_ASSERT_ZEXT %1(s32), 11
%3:_(s64) = G_ANYEXT %2(s32)
$x1 = COPY %3(s64)
...
---
name: test_combine_anyext_trunc_vec
body: |
bb.1:
liveins: $q0
; CHECK-LABEL: name: test_combine_anyext_trunc_vec
; CHECK: liveins: $q0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s64>) = COPY $q0
; CHECK-NEXT: $q0 = COPY [[COPY]](<2 x s64>)
%0:_(<2 x s64>) = COPY $q0
%1:_(<2 x s32>) = G_TRUNC %0(<2 x s64>)
%2:_(<2 x s64>) = G_ANYEXT %1(<2 x s32>)
$q0 = COPY %2(<2 x s64>)
...
---
name: test_combine_anyext_anyext
body: |
bb.1:
liveins: $h0
; CHECK-LABEL: name: test_combine_anyext_anyext
; CHECK: liveins: $h0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $h0
; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[COPY]](s16)
; CHECK-NEXT: $x0 = COPY [[ANYEXT]](s64)
%0:_(s16) = COPY $h0
%1:_(s32) = G_ANYEXT %0(s16)
%2:_(s64) = G_ANYEXT %1(s32)
$x0 = COPY %2(s64)
...
---
name: test_combine_anyext_anyext_with_hint
body: |
bb.1:
liveins: $h0
; CHECK-LABEL: name: test_combine_anyext_anyext_with_hint
; CHECK: liveins: $h0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $h0
; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[COPY]](s16)
; CHECK-NEXT: $x0 = COPY [[ANYEXT]](s64)
%0:_(s16) = COPY $h0
%1:_(s32) = G_ANYEXT %0(s16)
%2:_(s32) = G_ASSERT_ZEXT %1(s32), 11
%3:_(s64) = G_ANYEXT %2(s32)
$x0 = COPY %3(s64)
...
---
name: test_combine_anyext_anyext_vec
body: |
bb.1:
liveins: $s0
; CHECK-LABEL: name: test_combine_anyext_anyext_vec
; CHECK: liveins: $s0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s16>) = COPY $s0
; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(<2 x s64>) = G_ANYEXT [[COPY]](<2 x s16>)
; CHECK-NEXT: $q0 = COPY [[ANYEXT]](<2 x s64>)
%0:_(<2 x s16>) = COPY $s0
%1:_(<2 x s32>) = G_ANYEXT %0(<2 x s16>)
%2:_(<2 x s64>) = G_ANYEXT %1(<2 x s32>)
$q0 = COPY %2(<2 x s64>)
...
---
name: test_combine_anyext_sext
body: |
bb.1:
liveins: $h0
; CHECK-LABEL: name: test_combine_anyext_sext
; CHECK: liveins: $h0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $h0
; CHECK-NEXT: [[SEXT:%[0-9]+]]:_(s64) = G_SEXT [[COPY]](s16)
; CHECK-NEXT: $x0 = COPY [[SEXT]](s64)
%0:_(s16) = COPY $h0
%1:_(s32) = G_SEXT %0(s16)
%2:_(s64) = G_ANYEXT %1(s32)
$x0 = COPY %2(s64)
...
---
name: test_combine_anyext_sext_with_hint
body: |
bb.1:
liveins: $h0
; CHECK-LABEL: name: test_combine_anyext_sext_with_hint
; CHECK: liveins: $h0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $h0
; CHECK-NEXT: [[SEXT:%[0-9]+]]:_(s64) = G_SEXT [[COPY]](s16)
; CHECK-NEXT: $x0 = COPY [[SEXT]](s64)
%0:_(s16) = COPY $h0
%1:_(s32) = G_SEXT %0(s16)
%2:_(s32) = G_ASSERT_ZEXT %1(s32), 11
%3:_(s64) = G_ANYEXT %2(s32)
$x0 = COPY %3(s64)
...
---
name: test_combine_anyext_sext_vec
body: |
bb.1:
liveins: $s0
; CHECK-LABEL: name: test_combine_anyext_sext_vec
; CHECK: liveins: $s0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s16>) = COPY $s0
; CHECK-NEXT: [[SEXT:%[0-9]+]]:_(<2 x s64>) = G_SEXT [[COPY]](<2 x s16>)
; CHECK-NEXT: $q0 = COPY [[SEXT]](<2 x s64>)
%0:_(<2 x s16>) = COPY $s0
%1:_(<2 x s32>) = G_SEXT %0(<2 x s16>)
%2:_(<2 x s64>) = G_ANYEXT %1(<2 x s32>)
$q0 = COPY %2(<2 x s64>)
...
---
name: test_combine_anyext_zext
body: |
bb.1:
liveins: $h0
; CHECK-LABEL: name: test_combine_anyext_zext
; CHECK: liveins: $h0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $h0
; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s16)
; CHECK-NEXT: $x0 = COPY [[ZEXT]](s64)
%0:_(s16) = COPY $h0
%1:_(s32) = G_ZEXT %0(s16)
%2:_(s64) = G_ANYEXT %1(s32)
$x0 = COPY %2(s64)
...
---
name: test_combine_anyext_zext_with_hint
body: |
bb.1:
liveins: $h0
; CHECK-LABEL: name: test_combine_anyext_zext_with_hint
; CHECK: liveins: $h0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $h0
; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s16)
; CHECK-NEXT: $x0 = COPY [[ZEXT]](s64)
%0:_(s16) = COPY $h0
%1:_(s32) = G_ZEXT %0(s16)
%2:_(s32) = G_ASSERT_ZEXT %1(s32), 11
%3:_(s64) = G_ANYEXT %2(s32)
$x0 = COPY %3(s64)
...
---
name: test_combine_anyext_zext_vec
body: |
bb.1:
liveins: $s0
; CHECK-LABEL: name: test_combine_anyext_zext_vec
; CHECK: liveins: $s0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s16>) = COPY $s0
; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(<2 x s64>) = G_ZEXT [[COPY]](<2 x s16>)
; CHECK-NEXT: $q0 = COPY [[ZEXT]](<2 x s64>)
%0:_(<2 x s16>) = COPY $s0
%1:_(<2 x s32>) = G_ZEXT %0(<2 x s16>)
%2:_(<2 x s64>) = G_ANYEXT %1(<2 x s32>)
$q0 = COPY %2(<2 x s64>)
...
---
name: test_combine_sext_sext
body: |
bb.1:
liveins: $h0
; CHECK-LABEL: name: test_combine_sext_sext
; CHECK: liveins: $h0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $h0
; CHECK-NEXT: [[SEXT:%[0-9]+]]:_(s64) = G_SEXT [[COPY]](s16)
; CHECK-NEXT: $x0 = COPY [[SEXT]](s64)
%0:_(s16) = COPY $h0
%1:_(s32) = G_SEXT %0(s16)
%2:_(s64) = G_SEXT %1(s32)
$x0 = COPY %2(s64)
...
---
name: test_combine_sext_sext_with_hint
body: |
bb.1:
liveins: $h0
; CHECK-LABEL: name: test_combine_sext_sext_with_hint
; CHECK: liveins: $h0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $h0
; CHECK-NEXT: [[SEXT:%[0-9]+]]:_(s64) = G_SEXT [[COPY]](s16)
; CHECK-NEXT: $x0 = COPY [[SEXT]](s64)
%0:_(s16) = COPY $h0
%1:_(s32) = G_SEXT %0(s16)
%2:_(s32) = G_ASSERT_SEXT %1(s32), 11
%3:_(s64) = G_SEXT %2(s32)
$x0 = COPY %3(s64)
...
---
name: test_combine_sext_sext_vec
body: |
bb.1:
liveins: $s0
; CHECK-LABEL: name: test_combine_sext_sext_vec
; CHECK: liveins: $s0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s16>) = COPY $s0
; CHECK-NEXT: [[SEXT:%[0-9]+]]:_(<2 x s64>) = G_SEXT [[COPY]](<2 x s16>)
; CHECK-NEXT: $q0 = COPY [[SEXT]](<2 x s64>)
%0:_(<2 x s16>) = COPY $s0
%1:_(<2 x s32>) = G_SEXT %0(<2 x s16>)
%2:_(<2 x s64>) = G_SEXT %1(<2 x s32>)
$q0 = COPY %2(<2 x s64>)
...
---
name: test_combine_sext_zext
body: |
bb.1:
liveins: $h0
; CHECK-LABEL: name: test_combine_sext_zext
; CHECK: liveins: $h0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $h0
; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[COPY]](s16)
; CHECK-NEXT: [[SEXT:%[0-9]+]]:_(s64) = G_SEXT [[ZEXT]](s32)
; CHECK-NEXT: $x0 = COPY [[SEXT]](s64)
%0:_(s16) = COPY $h0
%1:_(s32) = G_ZEXT %0(s16)
%2:_(s64) = G_SEXT %1(s32)
$x0 = COPY %2(s64)
...
---
name: test_combine_sext_zext_with_hint
body: |
bb.1:
liveins: $h0
; CHECK-LABEL: name: test_combine_sext_zext_with_hint
; CHECK: liveins: $h0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $h0
; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[COPY]](s16)
; CHECK-NEXT: [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[ZEXT]], 11
; CHECK-NEXT: [[SEXT:%[0-9]+]]:_(s64) = G_SEXT [[ASSERT_ZEXT]](s32)
; CHECK-NEXT: $x0 = COPY [[SEXT]](s64)
%0:_(s16) = COPY $h0
%1:_(s32) = G_ZEXT %0(s16)
%2:_(s32) = G_ASSERT_ZEXT %1(s32), 11
%3:_(s64) = G_SEXT %2(s32)
$x0 = COPY %3(s64)
...
---
name: test_combine_sext_zext_vec
body: |
bb.1:
liveins: $s0
; CHECK-LABEL: name: test_combine_sext_zext_vec
; CHECK: liveins: $s0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s16>) = COPY $s0
; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(<2 x s32>) = G_ZEXT [[COPY]](<2 x s16>)
; CHECK-NEXT: [[SEXT:%[0-9]+]]:_(<2 x s64>) = G_SEXT [[ZEXT]](<2 x s32>)
; CHECK-NEXT: $q0 = COPY [[SEXT]](<2 x s64>)
%0:_(<2 x s16>) = COPY $s0
%1:_(<2 x s32>) = G_ZEXT %0(<2 x s16>)
%2:_(<2 x s64>) = G_SEXT %1(<2 x s32>)
$q0 = COPY %2(<2 x s64>)
...
---
name: test_combine_zext_zext
body: |
bb.1:
liveins: $h0
; CHECK-LABEL: name: test_combine_zext_zext
; CHECK: liveins: $h0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $h0
; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s16)
; CHECK-NEXT: $x0 = COPY [[ZEXT]](s64)
%0:_(s16) = COPY $h0
%1:_(s32) = G_ZEXT %0(s16)
%2:_(s64) = G_ZEXT %1(s32)
$x0 = COPY %2(s64)
...
---
name: test_combine_zext_zext_with_hint
body: |
bb.1:
liveins: $h0
; CHECK-LABEL: name: test_combine_zext_zext_with_hint
; CHECK: liveins: $h0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $h0
; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s16)
; CHECK-NEXT: $x0 = COPY [[ZEXT]](s64)
%0:_(s16) = COPY $h0
%1:_(s32) = G_ZEXT %0(s16)
%2:_(s32) = G_ASSERT_ZEXT %1(s32), 11
%3:_(s64) = G_ZEXT %2(s32)
$x0 = COPY %3(s64)
...
---
name: test_combine_zext_zext_vec
body: |
bb.1:
liveins: $s0
; CHECK-LABEL: name: test_combine_zext_zext_vec
; CHECK: liveins: $s0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s16>) = COPY $s0
; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(<2 x s64>) = G_ZEXT [[COPY]](<2 x s16>)
; CHECK-NEXT: $q0 = COPY [[ZEXT]](<2 x s64>)
%0:_(<2 x s16>) = COPY $s0
%1:_(<2 x s32>) = G_ZEXT %0(<2 x s16>)
%2:_(<2 x s64>) = G_ZEXT %1(<2 x s32>)
$q0 = COPY %2(<2 x s64>)
...
---
name: test_combine_zext_anyext
body: |
bb.1:
liveins: $h0
; CHECK-LABEL: name: test_combine_zext_anyext
; CHECK: liveins: $h0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $h0
; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s16)
; CHECK-NEXT: $x0 = COPY [[ZEXT]](s64)
%0:_(s16) = COPY $h0
%1:_(s32) = G_ANYEXT %0(s16)
%2:_(s64) = G_ZEXT %1(s32)
$x0 = COPY %2(s64)
...
---
name: test_combine_sext_anyext
body: |
bb.1:
liveins: $h0
; CHECK-LABEL: name: test_combine_sext_anyext
; CHECK: liveins: $h0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $h0
; CHECK-NEXT: [[SEXT:%[0-9]+]]:_(s64) = G_SEXT [[COPY]](s16)
; CHECK-NEXT: $x0 = COPY [[SEXT]](s64)
%0:_(s16) = COPY $h0
%1:_(s32) = G_ANYEXT %0(s16)
%2:_(s64) = G_SEXT %1(s32)
$x0 = COPY %2(s64)
...
---
name: test_combine_nneg_zext_anyext
body: |
bb.1:
liveins: $h0
; CHECK-LABEL: name: test_combine_nneg_zext_anyext
; CHECK: liveins: $h0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $h0
; CHECK-NEXT: %2:_(s64) = nneg G_ZEXT [[COPY]](s16)
; CHECK-NEXT: $x0 = COPY %2(s64)
%0:_(s16) = COPY $h0
%1:_(s32) = G_ANYEXT %0(s16)
%2:_(s64) = nneg G_ZEXT %1(s32)
$x0 = COPY %2(s64)
...
---
name: test_combine_anyext_nneg_zext
body: |
bb.1:
liveins: $h0
; CHECK-LABEL: name: test_combine_anyext_nneg_zext
; CHECK: liveins: $h0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $h0
; CHECK-NEXT: %2:_(s64) = nneg G_ZEXT [[COPY]](s16)
; CHECK-NEXT: $x0 = COPY %2(s64)
%0:_(s16) = COPY $h0
%1:_(s32) = nneg G_ZEXT %0(s16)
%2:_(s64) = G_ANYEXT %1(s32)
$x0 = COPY %2(s64)
...