From bf82f44e7b9769c5de3cb62a984fed83016963d1 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Thu, 4 Aug 2016 16:48:30 +0000 Subject: [PATCH] add tests for missing vector folds llvm-svn: 277736 --- llvm/test/Transforms/InstSimplify/compare.ll | 36 +++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/llvm/test/Transforms/InstSimplify/compare.ll b/llvm/test/Transforms/InstSimplify/compare.ll index 9d6fd74..4d30203 100644 --- a/llvm/test/Transforms/InstSimplify/compare.ll +++ b/llvm/test/Transforms/InstSimplify/compare.ll @@ -1005,22 +1005,46 @@ define i1 @nonnull_load_as_inner(i32 addrspace(1)** %addr) { ; If a bit is known to be zero for A and known to be one for B, ; then A and B cannot be equal. -define i1 @icmp_eq_const(i32 %a) nounwind { +define i1 @icmp_eq_const(i32 %a) { +; CHECK-LABEL: @icmp_eq_const( +; CHECK-NEXT: ret i1 false +; %b = mul nsw i32 %a, -2 %c = icmp eq i32 %b, 1 ret i1 %c +} -; CHECK-LABEL: @icmp_eq_const -; CHECK-NEXT: ret i1 false +; FIXME: Vectors should fold the same way. +define <2 x i1> @icmp_eq_const_vec(<2 x i32> %a) { +; CHECK-LABEL: @icmp_eq_const_vec( +; CHECK-NEXT: [[B:%.*]] = mul nsw <2 x i32> %a, +; CHECK-NEXT: [[C:%.*]] = icmp eq <2 x i32> [[B]], +; CHECK-NEXT: ret <2 x i1> [[C]] +; + %b = mul nsw <2 x i32> %a, + %c = icmp eq <2 x i32> %b, + ret <2 x i1> %c } -define i1 @icmp_ne_const(i32 %a) nounwind { +define i1 @icmp_ne_const(i32 %a) { +; CHECK-LABEL: @icmp_ne_const( +; CHECK-NEXT: ret i1 true +; %b = mul nsw i32 %a, -2 %c = icmp ne i32 %b, 1 ret i1 %c +} -; CHECK-LABEL: @icmp_ne_const -; CHECK-NEXT: ret i1 true +; FIXME: Vectors should fold the same way. +define <2 x i1> @icmp_ne_const_vec(<2 x i32> %a) { +; CHECK-LABEL: @icmp_ne_const_vec( +; CHECK-NEXT: [[B:%.*]] = mul nsw <2 x i32> %a, +; CHECK-NEXT: [[C:%.*]] = icmp ne <2 x i32> [[B]], +; CHECK-NEXT: ret <2 x i1> [[C]] +; + %b = mul nsw <2 x i32> %a, + %c = icmp ne <2 x i32> %b, + ret <2 x i1> %c } define i1 @icmp_sdiv_int_min(i32 %a) { -- 2.7.4