1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=aarch64-- | FileCheck %s
5 ; (X * Y) == 0 --> (X == 0) || (Y == 0)
6 ; (X * Y) != 0 --> (X != 0) && (Y != 0)
8 define i1 @mul_nsw_eq0_i8(i8 %x, i8 %y) {
9 ; CHECK-LABEL: mul_nsw_eq0_i8:
11 ; CHECK-NEXT: tst w0, #0xff
12 ; CHECK-NEXT: cset w8, eq
13 ; CHECK-NEXT: tst w1, #0xff
14 ; CHECK-NEXT: csinc w0, w8, wzr, ne
16 %m = mul nsw i8 %x, %y
21 ; negative test - not valid if mul can overflow
23 define i1 @mul_eq0_i8(i8 %x, i8 %y) {
24 ; CHECK-LABEL: mul_eq0_i8:
26 ; CHECK-NEXT: mul w8, w0, w1
27 ; CHECK-NEXT: tst w8, #0xff
28 ; CHECK-NEXT: cset w0, eq
35 ; negative test - don't try with minsize
37 define i1 @mul_nsw_eq0_i8_size(i8 %x, i8 %y) minsize {
38 ; CHECK-LABEL: mul_nsw_eq0_i8_size:
40 ; CHECK-NEXT: mul w8, w0, w1
41 ; CHECK-NEXT: tst w8, #0xff
42 ; CHECK-NEXT: cset w0, eq
44 %m = mul nsw i8 %x, %y
49 define i1 @mul_nsw_ne0_i16(i16 %x, i16 %y) {
50 ; CHECK-LABEL: mul_nsw_ne0_i16:
52 ; CHECK-NEXT: tst w0, #0xffff
53 ; CHECK-NEXT: cset w8, ne
54 ; CHECK-NEXT: tst w1, #0xffff
55 ; CHECK-NEXT: csel w0, wzr, w8, eq
57 %m = mul nsw i16 %x, %y
58 %r = icmp ne i16 %m, 0
62 define i1 @mul_nuw_eq0_i32(i32 %x, i32 %y) {
63 ; CHECK-LABEL: mul_nuw_eq0_i32:
65 ; CHECK-NEXT: cmp w0, #0
66 ; CHECK-NEXT: ccmp w1, #0, #4, ne
67 ; CHECK-NEXT: cset w0, eq
69 %m = mul nuw i32 %x, %y
70 %r = icmp eq i32 %m, 0
74 define i1 @mul_nsw_nuw_ne0_i64(i64 %x, i64 %y) {
75 ; CHECK-LABEL: mul_nsw_nuw_ne0_i64:
77 ; CHECK-NEXT: cmp x0, #0
78 ; CHECK-NEXT: ccmp x1, #0, #4, ne
79 ; CHECK-NEXT: cset w0, ne
81 %m = mul nsw nuw i64 %x, %y
82 %r = icmp ne i64 %m, 0
86 define <16 x i1> @mul_nuw_eq0_v16i8(<16 x i8> %x, <16 x i8> %y) {
87 ; CHECK-LABEL: mul_nuw_eq0_v16i8:
89 ; CHECK-NEXT: cmeq v1.16b, v1.16b, #0
90 ; CHECK-NEXT: cmeq v0.16b, v0.16b, #0
91 ; CHECK-NEXT: orr v0.16b, v0.16b, v1.16b
93 %m = mul nuw <16 x i8> %x, %y
94 %r = icmp eq <16 x i8> %m, zeroinitializer
98 define <4 x i1> @mul_nsw_ne0_v4i32(<4 x i32> %x, <4 x i32> %y) {
99 ; CHECK-LABEL: mul_nsw_ne0_v4i32:
101 ; CHECK-NEXT: cmtst v0.4s, v0.4s, v0.4s
102 ; CHECK-NEXT: cmeq v1.4s, v1.4s, #0
103 ; CHECK-NEXT: bic v0.16b, v0.16b, v1.16b
104 ; CHECK-NEXT: xtn v0.4h, v0.4s
106 %m = mul nsw <4 x i32> %x, %y
107 %r = icmp ne <4 x i32> %m, zeroinitializer
111 ; negative test - don't try with minsize
113 define <4 x i1> @mul_nsw_ne0_v4i32_size(<4 x i32> %x, <4 x i32> %y) minsize {
114 ; CHECK-LABEL: mul_nsw_ne0_v4i32_size:
116 ; CHECK-NEXT: mul v0.4s, v0.4s, v1.4s
117 ; CHECK-NEXT: cmtst v0.4s, v0.4s, v0.4s
118 ; CHECK-NEXT: xtn v0.4h, v0.4s
120 %m = mul nsw <4 x i32> %x, %y
121 %r = icmp ne <4 x i32> %m, zeroinitializer