Implement mul.ll:test11
authorChris Lattner <sabre@nondot.org>
Mon, 23 Feb 2004 06:00:11 +0000 (06:00 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 23 Feb 2004 06:00:11 +0000 (06:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11737 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index f23c10fcbd8e8df3d807e2d106a2a7b35c5d1998..a5fcbc92b91fde75bf7d9fe866a25583007414b4 100644 (file)
@@ -616,12 +616,13 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
       Value *SCIOp0 = SCI->getOperand(0), *SCIOp1 = SCI->getOperand(1);
       const Type *SCOpTy = SCIOp0->getType();
 
-      // If the source is X < 0, and X is a signed integer type, convert this
-      // multiply into a shift/and combination.
-      if (SCI->getOpcode() == Instruction::SetLT &&
-          isa<Constant>(SCIOp1) && cast<Constant>(SCIOp1)->isNullValue() &&
-          SCOpTy->isInteger() && SCOpTy->isSigned()) {
-
+      // If the source is X < 0 or X <= -1, and X is a signed integer type,
+      // convert this multiply into a shift/and combination.
+      if (SCOpTy->isSigned() && isa<ConstantInt>(SCIOp1) &&
+          ((SCI->getOpcode() == Instruction::SetLT &&
+            cast<Constant>(SCIOp1)->isNullValue()) ||
+           (SCI->getOpcode() == Instruction::SetLE &&
+            cast<ConstantInt>(SCIOp1)->isAllOnesValue()))) {
         // Shift the X value right to turn it into "all signbits".
         Constant *Amt = ConstantUInt::get(Type::UByteTy,
                                           SCOpTy->getPrimitiveSize()*8-1);