[llvm-commits] [llvm] r50793 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/mul-masked-bits.ll
Dan Gohman
gohman at apple.com
Tue May 6 17:35:56 PDT 2008
Author: djg
Date: Tue May 6 19:35:55 2008
New Revision: 50793
URL: http://llvm.org/viewvc/llvm-project?rev=50793&view=rev
Log:
Fix a bug in the ComputeMaskedBits logic for multiply.
Added:
llvm/trunk/test/Transforms/InstCombine/mul-masked-bits.ll
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=50793&r1=50792&r2=50793&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Tue May 6 19:35:55 2008
@@ -1244,8 +1244,8 @@
unsigned TrailZ = KnownZero.countTrailingOnes() +
KnownZero2.countTrailingOnes();
unsigned LeadZ = std::max(KnownZero.countLeadingOnes() +
- KnownZero2.countLeadingOnes() +
- 1, BitWidth) - BitWidth;
+ KnownZero2.countLeadingOnes(),
+ BitWidth) - BitWidth;
TrailZ = std::min(TrailZ, BitWidth);
LeadZ = std::min(LeadZ, BitWidth);
Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=50793&r1=50792&r2=50793&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Tue May 6 19:35:55 2008
@@ -767,8 +767,8 @@
unsigned TrailZ = KnownZero.countTrailingOnes() +
KnownZero2.countTrailingOnes();
unsigned LeadZ = std::max(KnownZero.countLeadingOnes() +
- KnownZero2.countLeadingOnes() +
- 1, BitWidth) - BitWidth;
+ KnownZero2.countLeadingOnes(),
+ BitWidth) - BitWidth;
TrailZ = std::min(TrailZ, BitWidth);
LeadZ = std::min(LeadZ, BitWidth);
Added: llvm/trunk/test/Transforms/InstCombine/mul-masked-bits.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/mul-masked-bits.ll?rev=50793&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/mul-masked-bits.ll (added)
+++ llvm/trunk/test/Transforms/InstCombine/mul-masked-bits.ll Tue May 6 19:35:55 2008
@@ -0,0 +1,10 @@
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep ashr
+
+define i32 @foo(i32 %x, i32 %y) {
+ %a = and i32 %x, 7
+ %b = and i32 %y, 7
+ %c = mul i32 %a, %b
+ %d = shl i32 %c, 26
+ %e = ashr i32 %d, 26
+ ret i32 %e
+}
More information about the llvm-commits
mailing list