1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=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> splat (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: [[Y:%.*]] = or <2 x i32> [[X:%.*]], <i32 undef, i32 1>
25 ; CHECK-NEXT: [[C:%.*]] = icmp eq <2 x i32> [[Y]], zeroinitializer
26 ; CHECK-NEXT: ret <2 x i1> [[C]]
28 %y = or <2 x i32> %x, <i32 undef, i32 1>
29 %c = icmp eq <2 x i32> %y, zeroinitializer
33 define <2 x i1> @nonzero_vec_poison_elt(<2 x i32> %x) {
34 ; CHECK-LABEL: @nonzero_vec_poison_elt(
35 ; CHECK-NEXT: ret <2 x i1> zeroinitializer
37 %y = or <2 x i32> %x, <i32 poison, i32 1>
38 %c = icmp eq <2 x i32> %y, zeroinitializer
42 define <2 x i1> @may_be_zero_vec(<2 x i32> %x) {
43 ; CHECK-LABEL: @may_be_zero_vec(
44 ; CHECK-NEXT: [[Y:%.*]] = or <2 x i32> [[X:%.*]], <i32 0, i32 1>
45 ; CHECK-NEXT: [[C:%.*]] = icmp ne <2 x i32> [[Y]], zeroinitializer
46 ; CHECK-NEXT: ret <2 x i1> [[C]]
48 %y = or <2 x i32> %x, <i32 0, i32 1>
49 %c = icmp ne <2 x i32> %y, zeroinitializer
53 ; Multiplies of non-zero numbers are non-zero if there is no unsigned overflow.
54 define <2 x i1> @nonzero_vec_mul_nuw(<2 x i32> %x, <2 x i32> %y) {
55 ; CHECK-LABEL: @nonzero_vec_mul_nuw(
56 ; CHECK-NEXT: ret <2 x i1> zeroinitializer
58 %xnz = or <2 x i32> %x, <i32 1, i32 2>
59 %ynz = or <2 x i32> %y, <i32 3, i32 poison>
60 %m = mul nuw <2 x i32> %xnz, %ynz
61 %c = icmp eq <2 x i32> %m, zeroinitializer
65 ; Multiplies of non-zero numbers are non-zero if there is no signed overflow.
66 define <2 x i1> @nonzero_vec_mul_nsw(<2 x i32> %x, <2 x i32> %y) {
67 ; CHECK-LABEL: @nonzero_vec_mul_nsw(
68 ; CHECK-NEXT: ret <2 x i1> splat (i1 true)
70 %xnz = or <2 x i32> %x, <i32 poison, i32 2>
71 %ynz = or <2 x i32> %y, <i32 3, i32 4>
72 %m = mul nsw <2 x i32> %xnz, %ynz
73 %c = icmp ne <2 x i32> %m, zeroinitializer