[llvm-branch-commits] [llvm-branch] r83763 - in /llvm/branches/Apple/Leela: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/mul.ll
Bill Wendling
isanbard at gmail.com
Sun Oct 11 01:55:16 PDT 2009
Author: void
Date: Sun Oct 11 03:55:16 2009
New Revision: 83763
URL: http://llvm.org/viewvc/llvm-project?rev=83763&view=rev
Log:
$ svn merge -c 83761 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r83761 into '.':
U test/Transforms/InstCombine/mul.ll
U lib/Transforms/Scalar/InstructionCombining.cpp
Modified:
llvm/branches/Apple/Leela/lib/Transforms/Scalar/InstructionCombining.cpp
llvm/branches/Apple/Leela/test/Transforms/InstCombine/mul.ll
Modified: llvm/branches/Apple/Leela/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/Transforms/Scalar/InstructionCombining.cpp?rev=83763&r1=83762&r2=83763&view=diff
==============================================================================
--- llvm/branches/Apple/Leela/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/branches/Apple/Leela/lib/Transforms/Scalar/InstructionCombining.cpp Sun Oct 11 03:55:16 2009
@@ -2661,7 +2661,7 @@
if (isa<UndefValue>(I.getOperand(1))) // undef * X -> 0
return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
- // Simplify mul instructions with a constant RHS...
+ // Simplify mul instructions with a constant RHS.
if (Constant *Op1 = dyn_cast<Constant>(I.getOperand(1))) {
if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) {
@@ -2765,9 +2765,20 @@
}
}
+ /// i1 mul -> i1 and.
if (I.getType() == Type::getInt1Ty(*Context))
return BinaryOperator::CreateAnd(Op0, I.getOperand(1));
+ // X*(1 << Y) --> X << Y
+ // (1 << Y)*X --> X << Y
+ {
+ Value *Y;
+ if (match(Op0, m_Shl(m_One(), m_Value(Y))))
+ return BinaryOperator::CreateShl(I.getOperand(1), Y);
+ if (match(I.getOperand(1), m_Shl(m_One(), m_Value(Y))))
+ return BinaryOperator::CreateShl(Op0, Y);
+ }
+
// If one of the operands of the multiply is a cast from a boolean value, then
// we know the bool is either zero or one, so this is a 'masking' multiply.
// See if we can simplify things based on how the boolean was originally
Modified: llvm/branches/Apple/Leela/test/Transforms/InstCombine/mul.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/test/Transforms/InstCombine/mul.ll?rev=83763&r1=83762&r2=83763&view=diff
==============================================================================
--- llvm/branches/Apple/Leela/test/Transforms/InstCombine/mul.ll (original)
+++ llvm/branches/Apple/Leela/test/Transforms/InstCombine/mul.ll Sun Oct 11 03:55:16 2009
@@ -88,3 +88,11 @@
%b = mul <16 x i8> %a, zeroinitializer
ret <16 x i8> %b
}
+
+; rdar://7293527
+define i32 @test15(i32 %A, i32 %B) {
+entry:
+ %shl = shl i32 1, %B
+ %m = mul i32 %shl, %A
+ ret i32 %m
+}
More information about the llvm-branch-commits
mailing list