# 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 --check-prefixes=CHECK
---
name: test_combine_trunc_xor_i64
body: |
bb.1:
; CHECK-LABEL: name: test_combine_trunc_xor_i64
; CHECK: %lhs:_(s64) = COPY $x0
; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC %lhs(s64)
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 5
; CHECK-NEXT: %small:_(s32) = G_XOR [[TRUNC]], [[C]]
; CHECK-NEXT: $w0 = COPY %small(s32)
%lhs:_(s64) = COPY $x0
%rhs:_(s64) = G_CONSTANT i64 5
%res:_(s64) = G_XOR %lhs, %rhs
%small:_(s32) = G_TRUNC %res(s64)
$w0 = COPY %small(s32)
...
---
name: test_combine_trunc_add_i64
body: |
bb.1:
; CHECK-LABEL: name: test_combine_trunc_add_i64
; CHECK: %lhs:_(s64) = COPY $x0
; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC %lhs(s64)
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 5
; CHECK-NEXT: %small:_(s32) = G_ADD [[TRUNC]], [[C]]
; CHECK-NEXT: $w0 = COPY %small(s32)
%lhs:_(s64) = COPY $x0
%rhs:_(s64) = G_CONSTANT i64 5
%res:_(s64) = G_ADD %lhs, %rhs
%small:_(s32) = G_TRUNC %res(s64)
$w0 = COPY %small(s32)
...
---
name: test_combine_trunc_mul_i64
body: |
bb.1:
; CHECK-LABEL: name: test_combine_trunc_mul_i64
; CHECK: %lhs:_(s64) = COPY $x0
; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC %lhs(s64)
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 5
; CHECK-NEXT: %small:_(s32) = G_MUL [[TRUNC]], [[C]]
; CHECK-NEXT: $w0 = COPY %small(s32)
%lhs:_(s64) = COPY $x0
%rhs:_(s64) = G_CONSTANT i64 5
%res:_(s64) = G_MUL %lhs, %rhs
%small:_(s32) = G_TRUNC %res(s64)
$w0 = COPY %small(s32)
...
---
name: test_combine_trunc_and_i64
body: |
bb.1:
; CHECK-LABEL: name: test_combine_trunc_and_i64
; CHECK: %lhs:_(s64) = COPY $x0
; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC %lhs(s64)
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 5
; CHECK-NEXT: %small:_(s32) = G_AND [[TRUNC]], [[C]]
; CHECK-NEXT: $w0 = COPY %small(s32)
%lhs:_(s64) = COPY $x0
%rhs:_(s64) = G_CONSTANT i64 5
%res:_(s64) = G_AND %lhs, %rhs
%small:_(s32) = G_TRUNC %res(s64)
$w0 = COPY %small(s32)
...
---
name: test_combine_trunc_or_i64
body: |
bb.1:
; CHECK-LABEL: name: test_combine_trunc_or_i64
; CHECK: %lhs:_(s64) = COPY $x0
; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC %lhs(s64)
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 5
; CHECK-NEXT: %small:_(s32) = G_OR [[TRUNC]], [[C]]
; CHECK-NEXT: $w0 = COPY %small(s32)
%lhs:_(s64) = COPY $x0
%rhs:_(s64) = G_CONSTANT i64 5
%res:_(s64) = G_OR %lhs, %rhs
%small:_(s32) = G_TRUNC %res(s64)
$w0 = COPY %small(s32)
...
---
name: test_combine_trunc_sub_i128
body: |
bb.1:
; CHECK-LABEL: name: test_combine_trunc_sub_i128
; CHECK: %lhs:_(s128) = COPY $q0
; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC %lhs(s128)
; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 5
; CHECK-NEXT: %small:_(s32) = G_SUB [[TRUNC]], [[C]]
; CHECK-NEXT: $w0 = COPY %small(s32)
%lhs:_(s128) = COPY $q0
%rhs:_(s128) = G_CONSTANT i128 5
%res:_(s128) = G_SUB %lhs, %rhs
%small:_(s32) = G_TRUNC %res(s128)
$w0 = COPY %small(s32)
...
---
name: test_combine_trunc_sub_i128_multi_use
body: |
bb.1:
; CHECK-LABEL: name: test_combine_trunc_sub_i128_multi_use
; CHECK: %lhs:_(s128) = COPY $q0
; CHECK-NEXT: %rhs:_(s128) = G_CONSTANT i128 5
; CHECK-NEXT: %res:_(s128) = G_SUB %lhs, %rhs
; CHECK-NEXT: %small:_(s32) = G_TRUNC %res(s128)
; CHECK-NEXT: $q0 = COPY %res(s128)
; CHECK-NEXT: $w0 = COPY %small(s32)
%lhs:_(s128) = COPY $q0
%rhs:_(s128) = G_CONSTANT i128 5
%res:_(s128) = G_SUB %lhs, %rhs
%small:_(s32) = G_TRUNC %res(s128)
$q0 = COPY %res(s128)
$w0 = COPY %small(s32)
...
---
name: test_combine_trunc_xor_vector_pattern_did_not_match
body: |
bb.1:
; CHECK-LABEL: name: test_combine_trunc_xor_vector_pattern_did_not_match
; CHECK: %arg1:_(s64) = COPY $x0
; CHECK-NEXT: %arg2:_(s64) = COPY $x0
; CHECK-NEXT: %lhs:_(<2 x s64>) = G_BUILD_VECTOR %arg1(s64), %arg2(s64)
; CHECK-NEXT: %rhs:_(<2 x s64>) = G_BUILD_VECTOR %arg1(s64), %arg2(s64)
; CHECK-NEXT: %res:_(<2 x s64>) = G_XOR %lhs, %rhs
; CHECK-NEXT: %small:_(<2 x s16>) = G_TRUNC %res(<2 x s64>)
; CHECK-NEXT: $w0 = COPY %small(<2 x s16>)
%arg1:_(s64) = COPY $x0
%arg2:_(s64) = COPY $x0
%lhs:_(<2 x s64>) = G_BUILD_VECTOR %arg1(s64), %arg2(s64)
%rhs:_(<2 x s64>) = G_BUILD_VECTOR %arg1(s64), %arg2(s64)
%res:_(<2 x s64>) = G_XOR %lhs, %rhs
%small:_(<2 x s16>) = G_TRUNC %res(<2 x s64>)
$w0 = COPY %small(<2 x s16>)