1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

[SCEV] Swap operands if LHS is not unknown.

Currently we only use information from guards for unknown expressions.
Swap LHS/RHS and predicate, if LHS is not unknown.
This commit is contained in:
Florian Hahn 2020-09-24 21:38:08 +01:00
parent 7d071a1cb8
commit 2bc55827ef
2 changed files with 6 additions and 1 deletions

View File

@ -12593,6 +12593,11 @@ const SCEV* ScalarEvolution::computeMaxBackedgeTakenCount(const Loop *L) {
const SCEV *ScalarEvolution::applyLoopGuards(const SCEV *Expr, const Loop *L) {
auto CollectCondition = [&](ICmpInst::Predicate Predicate, const SCEV *LHS,
const SCEV *RHS, ValueToSCEVMapTy &RewriteMap) {
if (!isa<SCEVUnknown>(LHS)) {
std::swap(LHS, RHS);
Predicate = CmpInst::getSwappedPredicate(Predicate);
}
// For now, limit to conditions that provide information about unknown
// expressions.
auto *LHSUnknown = dyn_cast<SCEVUnknown>(LHS);

View File

@ -28,7 +28,7 @@ exit:
define void @test_guard_less_than_16_operands_swapped(i32* nocapture %a, i64 %i) {
; CHECK-LABEL: Determining loop execution counts for: @test_guard_less_than_16_operands_swapped
; CHECK-NEXT: Loop %loop: backedge-taken count is (15 + (-1 * %i))
; CHECK-NEXT: Loop %loop: max backedge-taken count is -1
; CHECK-NEXT: Loop %loop: max backedge-taken count is 15
; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (15 + (-1 * %i))
;
entry: