blob: b5a02d670933bcf9b9ac77a53596e2bfde7c206e [file] [log] [blame]
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs -mtriple aarch64-unknown- --aarch64postlegalizercombiner-only-enable-rule="select_to_logical" %s -o - | FileCheck %s
# RUN: llc -debugify-and-strip-all-safe -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs -mtriple aarch64-unknown-unknown %s -o - | FileCheck %s
# REQUIRES: asserts
---
# select (c, x, x) -> x
name: test_combine_select_same_res
body: |
bb.1:
liveins: $x0, $x1
; CHECK-LABEL: name: test_combine_select_same_res
; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
; CHECK-NEXT: $x0 = COPY [[COPY]](s64)
%0:_(s64) = COPY $x0
%1:_(s1) = G_TRUNC %0
%2:_(s64) = G_SELECT %1, %0, %0
$x0 = COPY %2(s64)
...
---
# select (undef, x, y) -> y
name: test_combine_select_undef_res0_res1
body: |
bb.1:
liveins: $x0, $x1
; CHECK-LABEL: name: test_combine_select_undef_res0_res1
; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
; CHECK-NEXT: $x0 = COPY [[COPY]](s64)
%0:_(s64) = COPY $x0
%1:_(s64) = COPY $x1
%2:_(s1) = G_IMPLICIT_DEF
%3:_(s64) = G_SELECT %2, %0, %1
$x0 = COPY %3(s64)
...
---
# select (false, x, y) -> y
name: test_combine_select_false_res0_res1
body: |
bb.1:
liveins: $x0, $x1
; CHECK-LABEL: name: test_combine_select_false_res0_res1
; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x1
; CHECK-NEXT: $x0 = COPY [[COPY]](s64)
%0:_(s64) = COPY $x0
%1:_(s64) = COPY $x1
%2:_(s1) = G_CONSTANT i1 false
%3:_(s64) = G_SELECT %2, %0, %1
$x0 = COPY %3(s64)
...
---
# vector select (false, x, y) -> y
name: test_combine_vector_select_false_res0_res1
body: |
bb.1:
liveins: $q0, $q1
; CHECK-LABEL: name: test_combine_vector_select_false_res0_res1
; CHECK: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q1
; CHECK-NEXT: $q0 = COPY [[COPY]](<4 x s32>)
%0:_(<4 x s32>) = COPY $q0
%1:_(<4 x s32>) = COPY $q1
%2:_(s1) = G_CONSTANT i1 false
%condvec:_(<4 x s1>) = G_BUILD_VECTOR %2, %2, %2, %2
%3:_(<4 x s32>) = G_SELECT %condvec, %0, %1
$q0 = COPY %3(<4 x s32>)
...
---
# select (true, x, y) -> x
name: test_combine_select_true_res0_res1
body: |
bb.1:
liveins: $x0, $x1
; CHECK-LABEL: name: test_combine_select_true_res0_res1
; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
; CHECK-NEXT: $x0 = COPY [[COPY]](s64)
%0:_(s64) = COPY $x0
%1:_(s64) = COPY $x1
%2:_(s1) = G_CONSTANT i1 true
%3:_(s64) = G_SELECT %2, %0, %1
$x0 = COPY %3(s64)
...
---
# vector select (true, x, y) -> x
name: test_combine_vector_select_true_res0_res1
body: |
bb.1:
liveins: $q0, $q1
; CHECK-LABEL: name: test_combine_vector_select_true_res0_res1
; CHECK: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q0
; CHECK-NEXT: $q0 = COPY [[COPY]](<4 x s32>)
%0:_(<4 x s32>) = COPY $q0
%1:_(<4 x s32>) = COPY $q1
%2:_(s1) = G_CONSTANT i1 true
%condvec:_(<4 x s1>) = G_BUILD_VECTOR %2, %2, %2, %2
%3:_(<4 x s32>) = G_SELECT %condvec, %0, %1
$q0 = COPY %3(<4 x s32>)
...
---
# select Cond, Cond, F --> or Cond, F
name: bool_cond_cond_false
body: |
bb.1:
liveins: $x0, $x1, $x2
; CHECK-LABEL: name: bool_cond_cond_false
; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x2
; CHECK-NEXT: %c:_(s1) = G_TRUNC [[COPY]](s64)
; CHECK-NEXT: %f:_(s1) = G_TRUNC [[COPY1]](s64)
; CHECK-NEXT: %sel:_(s1) = G_OR %c, %f
; CHECK-NEXT: %ext:_(s32) = G_ANYEXT %sel(s1)
; CHECK-NEXT: $w0 = COPY %ext(s32)
%0:_(s64) = COPY $x0
%1:_(s64) = COPY $x1
%2:_(s64) = COPY $x2
%c:_(s1) = G_TRUNC %0
%t:_(s1) = G_TRUNC %1
%f:_(s1) = G_TRUNC %2
%sel:_(s1) = G_SELECT %c, %c, %f
%ext:_(s32) = G_ANYEXT %sel
$w0 = COPY %ext(s32)
...
---
# select Cond, 1, F --> or Cond, F
name: bool_cond_one_false
body: |
bb.1:
liveins: $x0, $x1, $x2
; CHECK-LABEL: name: bool_cond_one_false
; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x2
; CHECK-NEXT: %c:_(s1) = G_TRUNC [[COPY]](s64)
; CHECK-NEXT: %f:_(s1) = G_TRUNC [[COPY1]](s64)
; CHECK-NEXT: %sel:_(s1) = G_OR %c, %f
; CHECK-NEXT: %ext:_(s32) = G_ANYEXT %sel(s1)
; CHECK-NEXT: $w0 = COPY %ext(s32)
%0:_(s64) = COPY $x0
%1:_(s64) = COPY $x1
%2:_(s64) = COPY $x2
%c:_(s1) = G_TRUNC %0
%t:_(s1) = G_TRUNC %1
%f:_(s1) = G_TRUNC %2
%one:_(s1) = G_CONSTANT i1 1
%sel:_(s1) = G_SELECT %c, %one, %f
%ext:_(s32) = G_ANYEXT %sel
$w0 = COPY %ext(s32)
...
---
# select Cond, 1, F --> or Cond, F
name: bool_cond_one_false_vector
body: |
bb.1:
liveins: $d0, $d1, $d2
; CHECK-LABEL: name: bool_cond_one_false_vector
; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $d0
; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $d2
; CHECK-NEXT: %c:_(<2 x s1>) = G_TRUNC [[COPY]](<2 x s32>)
; CHECK-NEXT: %f:_(<2 x s1>) = G_TRUNC [[COPY1]](<2 x s32>)
; CHECK-NEXT: %sel:_(<2 x s1>) = G_OR %c, %f
; CHECK-NEXT: %ext:_(<2 x s32>) = G_ANYEXT %sel(<2 x s1>)
; CHECK-NEXT: $d0 = COPY %ext(<2 x s32>)
%0:_(<2 x s32>) = COPY $d0
%1:_(<2 x s32>) = COPY $d1
%2:_(<2 x s32>) = COPY $d2
%c:_(<2 x s1>) = G_TRUNC %0
%t:_(<2 x s1>) = G_TRUNC %1
%f:_(<2 x s1>) = G_TRUNC %2
%one:_(s1) = G_CONSTANT i1 1
%one_vec:_(<2 x s1>) = G_BUILD_VECTOR %one, %one
%sel:_(<2 x s1>) = G_SELECT %c, %one_vec, %f
%ext:_(<2 x s32>) = G_ANYEXT %sel
$d0 = COPY %ext(<2 x s32>)
...
---
# select Cond, T, Cond --> and Cond, T
name: bool_cond_true_cond
body: |
bb.1:
liveins: $x0, $x1, $x2
; CHECK-LABEL: name: bool_cond_true_cond
; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
; CHECK-NEXT: %c:_(s1) = G_TRUNC [[COPY]](s64)
; CHECK-NEXT: %t:_(s1) = G_TRUNC [[COPY1]](s64)
; CHECK-NEXT: %sel:_(s1) = G_AND %c, %t
; CHECK-NEXT: %ext:_(s32) = G_ANYEXT %sel(s1)
; CHECK-NEXT: $w0 = COPY %ext(s32)
%0:_(s64) = COPY $x0
%1:_(s64) = COPY $x1
%2:_(s64) = COPY $x2
%c:_(s1) = G_TRUNC %0
%t:_(s1) = G_TRUNC %1
%f:_(s1) = G_TRUNC %2
%one:_(s1) = G_CONSTANT i1 1
%sel:_(s1) = G_SELECT %c, %t, %c
%ext:_(s32) = G_ANYEXT %sel
$w0 = COPY %ext(s32)
...
---
# select Cond, T, 0 --> and Cond, T
name: bool_cond_true_zero
body: |
bb.1:
liveins: $x0, $x1, $x2
; CHECK-LABEL: name: bool_cond_true_zero
; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
; CHECK-NEXT: %c:_(s1) = G_TRUNC [[COPY]](s64)
; CHECK-NEXT: %t:_(s1) = G_TRUNC [[COPY1]](s64)
; CHECK-NEXT: %sel:_(s1) = G_AND %c, %t
; CHECK-NEXT: %ext:_(s32) = G_ANYEXT %sel(s1)
; CHECK-NEXT: $w0 = COPY %ext(s32)
%0:_(s64) = COPY $x0
%1:_(s64) = COPY $x1
%2:_(s64) = COPY $x2
%c:_(s1) = G_TRUNC %0
%t:_(s1) = G_TRUNC %1
%f:_(s1) = G_TRUNC %2
%zero:_(s1) = G_CONSTANT i1 0
%sel:_(s1) = G_SELECT %c, %t, %zero
%ext:_(s32) = G_ANYEXT %sel
$w0 = COPY %ext(s32)
...
---
# select Cond, T, 1 --> or (not Cond), T
name: bool_cond_true_one
body: |
bb.1:
liveins: $x0, $x1, $x2
; CHECK-LABEL: name: bool_cond_true_one
; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
; CHECK-NEXT: %c:_(s1) = G_TRUNC [[COPY]](s64)
; CHECK-NEXT: %t:_(s1) = G_TRUNC [[COPY1]](s64)
; CHECK-NEXT: %one:_(s1) = G_CONSTANT i1 true
; CHECK-NEXT: [[XOR:%[0-9]+]]:_(s1) = G_XOR %c, %one
; CHECK-NEXT: %sel:_(s1) = G_OR [[XOR]], %t
; CHECK-NEXT: %ext:_(s32) = G_ANYEXT %sel(s1)
; CHECK-NEXT: $w0 = COPY %ext(s32)
%0:_(s64) = COPY $x0
%1:_(s64) = COPY $x1
%2:_(s64) = COPY $x2
%c:_(s1) = G_TRUNC %0
%t:_(s1) = G_TRUNC %1
%f:_(s1) = G_TRUNC %2
%one:_(s1) = G_CONSTANT i1 1
%sel:_(s1) = G_SELECT %c, %t, %one
%ext:_(s32) = G_ANYEXT %sel
$w0 = COPY %ext(s32)
...
---
# select Cond, 0, F --> and (not Cond), F
name: bool_cond_zero_false
body: |
bb.1:
liveins: $x0, $x1, $x2
; CHECK-LABEL: name: bool_cond_zero_false
; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x2
; CHECK-NEXT: %c:_(s1) = G_TRUNC [[COPY]](s64)
; CHECK-NEXT: %f:_(s1) = G_TRUNC [[COPY1]](s64)
; CHECK-NEXT: [[C:%[0-9]+]]:_(s1) = G_CONSTANT i1 true
; CHECK-NEXT: [[XOR:%[0-9]+]]:_(s1) = G_XOR %c, [[C]]
; CHECK-NEXT: %sel:_(s1) = G_AND [[XOR]], %f
; CHECK-NEXT: %ext:_(s32) = G_ANYEXT %sel(s1)
; CHECK-NEXT: $w0 = COPY %ext(s32)
%0:_(s64) = COPY $x0
%1:_(s64) = COPY $x1
%2:_(s64) = COPY $x2
%c:_(s1) = G_TRUNC %0
%t:_(s1) = G_TRUNC %1
%f:_(s1) = G_TRUNC %2
%zero:_(s1) = G_CONSTANT i1 0
%sel:_(s1) = G_SELECT %c, %zero, %f
%ext:_(s32) = G_ANYEXT %sel
$w0 = COPY %ext(s32)
...