From 23019d10067506639ea7221855befbfdd6a25d75 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Tue, 24 May 2016 14:18:49 +0000 Subject: [ValueTracking, InstSimplify] extend isKnownNonZero() to handle vector constants Similar in spirit to D20497 : If all elements of a constant vector are known non-zero, then we can say that the whole vector is known non-zero. It seems like we could extend this to FP scalar/vector too, but isKnownNonZero() says it only works for integers and pointers for now. Differential Revision: http://reviews.llvm.org/D20544 llvm-svn: 270562 --- llvm/test/Transforms/InstSimplify/vec-cmp.ll | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) (limited to 'llvm/test/Transforms/InstSimplify/vec-cmp.ll') diff --git a/llvm/test/Transforms/InstSimplify/vec-cmp.ll b/llvm/test/Transforms/InstSimplify/vec-cmp.ll index 1fa817775d6..ca6361a18ac 100644 --- a/llvm/test/Transforms/InstSimplify/vec-cmp.ll +++ b/llvm/test/Transforms/InstSimplify/vec-cmp.ll @@ -1,13 +1,9 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -instsimplify -S | FileCheck %s -; FIXME: isKnownNonZero should work for integer vectors. - define <2 x i1> @nonzero_vec_splat(<2 x i32> %x) { ; CHECK-LABEL: @nonzero_vec_splat( -; CHECK-NEXT: [[Y:%.*]] = or <2 x i32> %x, -; CHECK-NEXT: [[C:%.*]] = icmp eq <2 x i32> [[Y]], zeroinitializer -; CHECK-NEXT: ret <2 x i1> [[C]] +; CHECK-NEXT: ret <2 x i1> zeroinitializer ; %y = or <2 x i32> %x, %c = icmp eq <2 x i32> %y, zeroinitializer @@ -16,9 +12,7 @@ define <2 x i1> @nonzero_vec_splat(<2 x i32> %x) { define <2 x i1> @nonzero_vec_nonsplat(<2 x i32> %x) { ; CHECK-LABEL: @nonzero_vec_nonsplat( -; CHECK-NEXT: [[Y:%.*]] = or <2 x i32> %x, -; CHECK-NEXT: [[C:%.*]] = icmp ne <2 x i32> [[Y]], zeroinitializer -; CHECK-NEXT: ret <2 x i1> [[C]] +; CHECK-NEXT: ret <2 x i1> ; %y = or <2 x i32> %x, %c = icmp ne <2 x i32> %y, zeroinitializer @@ -27,9 +21,7 @@ define <2 x i1> @nonzero_vec_nonsplat(<2 x i32> %x) { define <2 x i1> @nonzero_vec_undef_elt(<2 x i32> %x) { ; CHECK-LABEL: @nonzero_vec_undef_elt( -; CHECK-NEXT: [[Y:%.*]] = or <2 x i32> %x, -; CHECK-NEXT: [[C:%.*]] = icmp eq <2 x i32> [[Y]], zeroinitializer -; CHECK-NEXT: ret <2 x i1> [[C]] +; CHECK-NEXT: ret <2 x i1> zeroinitializer ; %y = or <2 x i32> %x, %c = icmp eq <2 x i32> %y, zeroinitializer @@ -50,11 +42,7 @@ define <2 x i1> @may_be_zero_vec(<2 x i32> %x) { ; Multiplies of non-zero numbers are non-zero if there is no unsigned overflow. define <2 x i1> @nonzero_vec_mul_nuw(<2 x i32> %x, <2 x i32> %y) { ; CHECK-LABEL: @nonzero_vec_mul_nuw( -; CHECK-NEXT: [[XNZ:%.*]] = or <2 x i32> %x, -; CHECK-NEXT: [[YNZ:%.*]] = or <2 x i32> %y, -; CHECK-NEXT: [[M:%.*]] = mul nuw <2 x i32> [[XNZ]], [[YNZ]] -; CHECK-NEXT: [[C:%.*]] = icmp eq <2 x i32> [[M]], zeroinitializer -; CHECK-NEXT: ret <2 x i1> [[C]] +; CHECK-NEXT: ret <2 x i1> zeroinitializer ; %xnz = or <2 x i32> %x, %ynz = or <2 x i32> %y, @@ -66,11 +54,7 @@ define <2 x i1> @nonzero_vec_mul_nuw(<2 x i32> %x, <2 x i32> %y) { ; Multiplies of non-zero numbers are non-zero if there is no signed overflow. define <2 x i1> @nonzero_vec_mul_nsw(<2 x i32> %x, <2 x i32> %y) { ; CHECK-LABEL: @nonzero_vec_mul_nsw( -; CHECK-NEXT: [[XNZ:%.*]] = or <2 x i32> %x, -; CHECK-NEXT: [[YNZ:%.*]] = or <2 x i32> %y, -; CHECK-NEXT: [[M:%.*]] = mul nsw <2 x i32> [[XNZ]], [[YNZ]] -; CHECK-NEXT: [[C:%.*]] = icmp ne <2 x i32> [[M]], zeroinitializer -; CHECK-NEXT: ret <2 x i1> [[C]] +; CHECK-NEXT: ret <2 x i1> ; %xnz = or <2 x i32> %x, %ynz = or <2 x i32> %y, -- cgit v1.2.3