1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -instsimplify -S | FileCheck %s 3 4define <2 x i1> @nonzero_vec_splat(<2 x i32> %x) { 5; CHECK-LABEL: @nonzero_vec_splat( 6; CHECK-NEXT: ret <2 x i1> zeroinitializer 7; 8 %y = or <2 x i32> %x, <i32 1, i32 1> 9 %c = icmp eq <2 x i32> %y, zeroinitializer 10 ret <2 x i1> %c 11} 12 13define <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> 16; 17 %y = or <2 x i32> %x, <i32 2, i32 1> 18 %c = icmp ne <2 x i32> %y, zeroinitializer 19 ret <2 x i1> %c 20} 21 22define <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 25; 26 %y = or <2 x i32> %x, <i32 undef, i32 1> 27 %c = icmp eq <2 x i32> %y, zeroinitializer 28 ret <2 x i1> %c 29} 30 31define <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]] 36; 37 %y = or <2 x i32> %x, <i32 0, i32 1> 38 %c = icmp ne <2 x i32> %y, zeroinitializer 39 ret <2 x i1> %c 40} 41 42; Multiplies of non-zero numbers are non-zero if there is no unsigned overflow. 43define <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 46; 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 51 ret <2 x i1> %c 52} 53 54; Multiplies of non-zero numbers are non-zero if there is no signed overflow. 55define <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> 58; 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 63 ret <2 x i1> %c 64} 65 66