]> granicus.if.org Git - llvm/commitdiff
[InstSimplify] Teach SimplifyMulInst to recognize vectors of i1 as And. Not just...
authorCraig Topper <craig.topper@gmail.com>
Thu, 6 Apr 2017 17:33:37 +0000 (17:33 +0000)
committerCraig Topper <craig.topper@gmail.com>
Thu, 6 Apr 2017 17:33:37 +0000 (17:33 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299665 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/InstructionSimplify.cpp
test/Transforms/InstSimplify/mul.ll [new file with mode: 0644]

index 85fcbcccb2c1382560015370c3d554a033b2fdde..da0495c340b81057ea263d4335c0556706fc3c39 100644 (file)
@@ -930,7 +930,7 @@ static Value *SimplifyMulInst(Value *Op0, Value *Op1, const Query &Q,
     return X;
 
   // i1 mul -> and.
-  if (MaxRecurse && Op0->getType()->isIntegerTy(1))
+  if (MaxRecurse && Op0->getType()->getScalarType()->isIntegerTy(1))
     if (Value *V = SimplifyAndInst(Op0, Op1, Q, MaxRecurse-1))
       return V;
 
diff --git a/test/Transforms/InstSimplify/mul.ll b/test/Transforms/InstSimplify/mul.ll
new file mode 100644 (file)
index 0000000..0bf8f69
--- /dev/null
@@ -0,0 +1,11 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instsimplify -S | FileCheck %s
+
+define <2 x i1> @test1(<2 x i1> %a) {
+; CHECK-LABEL: @test1(
+; CHECK-NEXT:    ret <2 x i1> zeroinitializer
+;
+  %b = and <2 x i1> %a, <i1 true, i1 false>
+  %res = mul <2 x i1> %b, <i1 false, i1 true>
+  ret <2 x i1> %res
+}