forked from OSchip/llvm-project
InstCombine: Add a missing irem identity (X % X -> 0).
llvm-svn: 119538
This commit is contained in:
parent
b94e5a33b3
commit
07726c7d52
|
@ -551,6 +551,10 @@ Instruction *InstCombiner::commonIRemTransforms(BinaryOperator &I) {
|
|||
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())
|
||||
|
|
|
@ -81,3 +81,8 @@ define i32 @test12(i32 %i) {
|
|||
%tmp.5 = srem i32 %tmp.1, 2
|
||||
ret i32 %tmp.5
|
||||
}
|
||||
|
||||
define i32 @test13(i32 %i) {
|
||||
%x = srem i32 %i, %i
|
||||
ret i32 %x
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue