mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[SCEV] Fold (0 udiv %x) to 0
We have analogous rules in instsimplify, etc.., but were missing the same in SCEV. The fold is near trivial, but came up in the context of a larger change.
This commit is contained in:
parent
7110dfba97
commit
0b160e9666
@ -3268,6 +3268,11 @@ const SCEV *ScalarEvolution::getUDivExpr(const SCEV *LHS,
|
|||||||
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP))
|
if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP))
|
||||||
return S;
|
return S;
|
||||||
|
|
||||||
|
// 0 udiv Y == 0
|
||||||
|
if (const SCEVConstant *LHSC = dyn_cast<SCEVConstant>(LHS))
|
||||||
|
if (LHSC->getValue()->isZero())
|
||||||
|
return LHS;
|
||||||
|
|
||||||
if (const SCEVConstant *RHSC = dyn_cast<SCEVConstant>(RHS)) {
|
if (const SCEVConstant *RHSC = dyn_cast<SCEVConstant>(RHS)) {
|
||||||
if (RHSC->getValue()->isOne())
|
if (RHSC->getValue()->isOne())
|
||||||
return LHS; // X udiv 1 --> x
|
return LHS; // X udiv 1 --> x
|
||||||
|
@ -132,6 +132,6 @@ define i64 @test11(i64 %a) {
|
|||||||
; CHECK-LABEL: @test11
|
; CHECK-LABEL: @test11
|
||||||
%t0 = udiv i64 0, %a
|
%t0 = udiv i64 0, %a
|
||||||
; CHECK: %t0
|
; CHECK: %t0
|
||||||
; CHECK-NEXT: --> (0 /u %a)
|
; CHECK-NEXT: --> 0
|
||||||
ret i64 %t0
|
ret i64 %t0
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user