mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-07 01:38:26 +00:00
implement PR2328.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51176 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e44b1bd3dc
commit
b2ae9e34db
@ -3012,6 +3012,10 @@ Instruction *InstCombiner::commonDivTransforms(BinaryOperator &I) {
|
||||
Instruction *InstCombiner::commonIDivTransforms(BinaryOperator &I) {
|
||||
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
|
||||
|
||||
// (sdiv X, X) --> 1 (udiv X, X) --> 1
|
||||
if (Op0 == Op1)
|
||||
return ReplaceInstUsesWith(I, ConstantInt::get(I.getType(), 1));
|
||||
|
||||
if (Instruction *Common = commonDivTransforms(I))
|
||||
return Common;
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
; This test makes sure that div instructions are properly eliminated.
|
||||
;
|
||||
|
||||
; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep div
|
||||
; END.
|
||||
|
||||
define i32 @test1(i32 %A) {
|
||||
%B = sdiv i32 %A, 1 ; <i32> [#uses=1]
|
||||
@ -72,3 +70,15 @@ define i32 @test11(i32 %X, i1 %C) {
|
||||
%B = udiv i32 %X, %A ; <i32> [#uses=1]
|
||||
ret i32 %B
|
||||
}
|
||||
|
||||
; PR2328
|
||||
define i32 @test12(i32 %x) nounwind {
|
||||
%tmp3 = udiv i32 %x, %x ; 1
|
||||
ret i32 %tmp3
|
||||
}
|
||||
|
||||
define i32 @test13(i32 %x) nounwind {
|
||||
%tmp3 = sdiv i32 %x, %x ; 1
|
||||
ret i32 %tmp3
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user