1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instsimplify -S | FileCheck %s
4 define <2 x i1> @nonzero_vec_splat(<2 x i32> %x) {
5 ; CHECK-LABEL: @nonzero_vec_splat(
6 ; CHECK-NEXT: ret <2 x i1> zeroinitializer
8 %y = or <2 x i32> %x, <i32 1, i32 1>
9 %c = icmp eq <2 x i32> %y, zeroinitializer
13 define <2 x i1> @nonzero_vec_nonsplat(<2 x i32> %x) {
14 ; CHECK-LABEL: @nonzero_vec_nonsplat(
15 ; CHECK-NEXT: ret <2 x i1> <i1 true, i1 true>
17 %y = or <2 x i32> %x, <i32 2, i32 1>
18 %c = icmp ne <2 x i32> %y, zeroinitializer
22 define <2 x i1> @nonzero_vec_undef_elt(<2 x i32> %x) {
23 ; CHECK-LABEL: @nonzero_vec_undef_elt(
24 ; CHECK-NEXT: ret <2 x i1> zeroinitializer
26 %y = or <2 x i32> %x, <i32 undef, i32 1>
27 %c = icmp eq <2 x i32> %y, zeroinitializer
31 define <2 x i1> @may_be_zero_vec(<2 x i32> %x) {
32 ; CHECK-LABEL: @may_be_zero_vec(
33 ; CHECK-NEXT: [[Y:%.*]] = or <2 x i32> %x, <i32 0, i32 1>
34 ; CHECK-NEXT: [[C:%.*]] = icmp ne <2 x i32> [[Y]], zeroinitializer
35 ; CHECK-NEXT: ret <2 x i1> [[C]]
37 %y = or <2 x i32> %x, <i32 0, i32 1>
38 %c = icmp ne <2 x i32> %y, zeroinitializer
42 ; Multiplies of non-zero numbers are non-zero if there is no unsigned overflow.
43 define <2 x i1> @nonzero_vec_mul_nuw(<2 x i32> %x, <2 x i32> %y) {
44 ; CHECK-LABEL: @nonzero_vec_mul_nuw(
45 ; CHECK-NEXT: ret <2 x i1> zeroinitializer
47 %xnz = or <2 x i32> %x, <i32 1, i32 2>
48 %ynz = or <2 x i32> %y, <i32 3, i32 undef>
49 %m = mul nuw <2 x i32> %xnz, %ynz
50 %c = icmp eq <2 x i32> %m, zeroinitializer
54 ; Multiplies of non-zero numbers are non-zero if there is no signed overflow.
55 define <2 x i1> @nonzero_vec_mul_nsw(<2 x i32> %x, <2 x i32> %y) {
56 ; CHECK-LABEL: @nonzero_vec_mul_nsw(
57 ; CHECK-NEXT: ret <2 x i1> <i1 true, i1 true>
59 %xnz = or <2 x i32> %x, <i32 undef, i32 2>
60 %ynz = or <2 x i32> %y, <i32 3, i32 4>
61 %m = mul nsw <2 x i32> %xnz, %ynz
62 %c = icmp ne <2 x i32> %m, zeroinitializer