[llvm-commits] [llvm] r119538 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineMulDivRem.cpp test/Transforms/InstCombine/rem.ll
Benjamin Kramer
benny.kra at googlemail.com
Wed Nov 17 11:11:46 PST 2010
Author: d0k
Date: Wed Nov 17 13:11:46 2010
New Revision: 119538
URL: http://llvm.org/viewvc/llvm-project?rev=119538&view=rev
Log:
InstCombine: Add a missing irem identity (X % X -> 0).
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
llvm/trunk/test/Transforms/InstCombine/rem.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp?rev=119538&r1=119537&r2=119538&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp Wed Nov 17 13:11:46 2010
@@ -551,6 +551,10 @@
if (Instruction *common = commonRemTransforms(I))
return common;
+ // X % X == 0
+ if (Op0 == Op1)
+ return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
+
// 0 % X == 0 for integer, we don't need to preserve faults!
if (Constant *LHS = dyn_cast<Constant>(Op0))
if (LHS->isNullValue())
Modified: llvm/trunk/test/Transforms/InstCombine/rem.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/rem.ll?rev=119538&r1=119537&r2=119538&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/rem.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/rem.ll Wed Nov 17 13:11:46 2010
@@ -81,3 +81,8 @@
%tmp.5 = srem i32 %tmp.1, 2
ret i32 %tmp.5
}
+
+define i32 @test13(i32 %i) {
+ %x = srem i32 %i, %i
+ ret i32 %x
+}
More information about the llvm-commits
mailing list