diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2016-05-23 22:09:04 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2016-05-23 22:09:04 +0000 |
| commit | adcaef72382e367dcc6a12ab3980baa60b162489 (patch) | |
| tree | b40077eb83031f45b8760ac2655beae4403367d1 /llvm/test/Transforms/InstSimplify/vec-cmp.ll | |
| parent | 255d854d12570bf1bcfcf441ade6c61f8341f88e (diff) | |
| download | bcm5719-llvm-adcaef72382e367dcc6a12ab3980baa60b162489.tar.gz bcm5719-llvm-adcaef72382e367dcc6a12ab3980baa60b162489.zip | |
[InstSimplify] add vector tests for isKnownNonZero
llvm-svn: 270498
Diffstat (limited to 'llvm/test/Transforms/InstSimplify/vec-cmp.ll')
| -rw-r--r-- | llvm/test/Transforms/InstSimplify/vec-cmp.ll | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstSimplify/vec-cmp.ll b/llvm/test/Transforms/InstSimplify/vec-cmp.ll new file mode 100644 index 00000000000..1fa817775d6 --- /dev/null +++ b/llvm/test/Transforms/InstSimplify/vec-cmp.ll @@ -0,0 +1,81 @@ +; 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, <i32 1, i32 1> +; CHECK-NEXT: [[C:%.*]] = icmp eq <2 x i32> [[Y]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[C]] +; + %y = or <2 x i32> %x, <i32 1, i32 1> + %c = icmp eq <2 x i32> %y, zeroinitializer + ret <2 x i1> %c +} + +define <2 x i1> @nonzero_vec_nonsplat(<2 x i32> %x) { +; CHECK-LABEL: @nonzero_vec_nonsplat( +; CHECK-NEXT: [[Y:%.*]] = or <2 x i32> %x, <i32 2, i32 1> +; CHECK-NEXT: [[C:%.*]] = icmp ne <2 x i32> [[Y]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[C]] +; + %y = or <2 x i32> %x, <i32 2, i32 1> + %c = icmp ne <2 x i32> %y, zeroinitializer + ret <2 x i1> %c +} + +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, <i32 undef, i32 1> +; CHECK-NEXT: [[C:%.*]] = icmp eq <2 x i32> [[Y]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[C]] +; + %y = or <2 x i32> %x, <i32 undef, i32 1> + %c = icmp eq <2 x i32> %y, zeroinitializer + ret <2 x i1> %c +} + +define <2 x i1> @may_be_zero_vec(<2 x i32> %x) { +; CHECK-LABEL: @may_be_zero_vec( +; CHECK-NEXT: [[Y:%.*]] = or <2 x i32> %x, <i32 0, i32 1> +; CHECK-NEXT: [[C:%.*]] = icmp ne <2 x i32> [[Y]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[C]] +; + %y = or <2 x i32> %x, <i32 0, i32 1> + %c = icmp ne <2 x i32> %y, zeroinitializer + ret <2 x i1> %c +} + +; 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, <i32 1, i32 2> +; CHECK-NEXT: [[YNZ:%.*]] = or <2 x i32> %y, <i32 3, i32 undef> +; 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]] +; + %xnz = or <2 x i32> %x, <i32 1, i32 2> + %ynz = or <2 x i32> %y, <i32 3, i32 undef> + %m = mul nuw <2 x i32> %xnz, %ynz + %c = icmp eq <2 x i32> %m, zeroinitializer + ret <2 x i1> %c +} + +; 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, <i32 undef, i32 2> +; CHECK-NEXT: [[YNZ:%.*]] = or <2 x i32> %y, <i32 3, i32 4> +; 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]] +; + %xnz = or <2 x i32> %x, <i32 undef, i32 2> + %ynz = or <2 x i32> %y, <i32 3, i32 4> + %m = mul nsw <2 x i32> %xnz, %ynz + %c = icmp ne <2 x i32> %m, zeroinitializer + ret <2 x i1> %c +} + |

