For mul transforms, when checking for a cast from bool as either operand,
authorReid Spencer <rspencer@reidspencer.com>
Wed, 13 Dec 2006 08:33:33 +0000 (08:33 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Wed, 13 Dec 2006 08:33:33 +0000 (08:33 +0000)
make sure to also check that it is a zext from bool, not any other cast
operation type.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32539 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index 232e504971c454c17f178fe89629b3a61a84c63d..68089c2dd3600b09c9a689394c8158071ec614a3 100644 (file)
@@ -2172,11 +2172,13 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
   // formed.
   CastInst *BoolCast = 0;
   if (CastInst *CI = dyn_cast<CastInst>(I.getOperand(0)))
-    if (CI->getOperand(0)->getType() == Type::BoolTy)
+    if (CI->getOperand(0)->getType() == Type::BoolTy &&
+        CI->getOpcode() == Instruction::ZExt)
       BoolCast = CI;
   if (!BoolCast)
     if (CastInst *CI = dyn_cast<CastInst>(I.getOperand(1)))
-      if (CI->getOperand(0)->getType() == Type::BoolTy)
+      if (CI->getOperand(0)->getType() == Type::BoolTy &&
+        CI->getOpcode() == Instruction::ZExt)
         BoolCast = CI;
   if (BoolCast) {
     if (SetCondInst *SCI = dyn_cast<SetCondInst>(BoolCast->getOperand(0))) {