mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-08 03:30:22 +00:00
Revert "r219834 - Teach ScalarEvolution to sharpen range information"
This change breaks the asan buildbots: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/13468 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219878 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
43141a0764
commit
a0b0184b33
@ -6782,44 +6782,6 @@ bool ScalarEvolution::isImpliedCond(ICmpInst::Predicate Pred,
|
|||||||
RHS, LHS, FoundLHS, FoundRHS);
|
RHS, LHS, FoundLHS, FoundRHS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FoundPred == ICmpInst::ICMP_NE) {
|
|
||||||
// If we are predicated on something with range [a, b) known not
|
|
||||||
// equal to a, the range can be sharpened to [a + 1, b). Use this
|
|
||||||
// fact.
|
|
||||||
auto CheckRange = [this, Pred, LHS, RHS](const SCEV *C, const SCEV *V) {
|
|
||||||
if (!isa<SCEVConstant>(C)) return false;
|
|
||||||
|
|
||||||
ConstantInt *CI = cast<SCEVConstant>(C)->getValue();
|
|
||||||
APInt Min = ICmpInst::isSigned(Pred) ?
|
|
||||||
getSignedRange(V).getSignedMin() : getUnsignedRange(V).getUnsignedMin();
|
|
||||||
|
|
||||||
if (Min!= CI->getValue()) return false; // nothing to sharpen
|
|
||||||
Min++;
|
|
||||||
|
|
||||||
// We know V >= Min, in the same signedness as in Pred. We can
|
|
||||||
// use this to simplify slt and ult. If the range had a single
|
|
||||||
// value, Min, we now know that FoundValue can never be true;
|
|
||||||
// and any answer is a correct answer.
|
|
||||||
|
|
||||||
switch (Pred) {
|
|
||||||
case ICmpInst::ICMP_SGT:
|
|
||||||
case ICmpInst::ICMP_UGT:
|
|
||||||
return isImpliedCondOperands(Pred, LHS, RHS, V, getConstant(Min));
|
|
||||||
|
|
||||||
default:
|
|
||||||
llvm_unreachable("don't call with predicates other than ICMP_SGT "
|
|
||||||
"and ICMP_UGT");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if ((Pred == ICmpInst::ICMP_SGT) || (Pred == ICmpInst::ICMP_UGT)) {
|
|
||||||
// Inequality is reflexive -- check both the combinations.
|
|
||||||
if (CheckRange(FoundLHS, FoundRHS) || CheckRange(FoundRHS, FoundLHS)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check whether the actual condition is beyond sufficient.
|
// Check whether the actual condition is beyond sufficient.
|
||||||
if (FoundPred == ICmpInst::ICMP_EQ)
|
if (FoundPred == ICmpInst::ICMP_EQ)
|
||||||
if (ICmpInst::isTrueWhenEqual(Pred))
|
if (ICmpInst::isTrueWhenEqual(Pred))
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
;; RUN: opt -S < %s -indvars | FileCheck %s
|
|
||||||
|
|
||||||
;; Check if llvm can narrow !range metadata based on loop entry
|
|
||||||
;; predicates.
|
|
||||||
|
|
||||||
declare void @abort()
|
|
||||||
|
|
||||||
define i1 @bounded_below(i32* nocapture readonly %buffer) {
|
|
||||||
entry:
|
|
||||||
%length = load i32* %buffer, !range !0
|
|
||||||
%entry.pred = icmp eq i32 %length, 0
|
|
||||||
br i1 %entry.pred, label %abort, label %loop.preheader
|
|
||||||
|
|
||||||
loop.preheader:
|
|
||||||
br label %loop
|
|
||||||
|
|
||||||
loop:
|
|
||||||
%idx = phi i32 [ %idx.inc, %loop.next ], [ 0, %loop.preheader ]
|
|
||||||
%oob.pred = icmp slt i32 %idx, %length
|
|
||||||
br i1 %oob.pred, label %loop.next, label %oob
|
|
||||||
; CHECK: br i1 true, label %loop.next, label %oob
|
|
||||||
|
|
||||||
loop.next:
|
|
||||||
%idx.inc = add i32 %idx, 1
|
|
||||||
%exit.pred = icmp slt i32 %idx.inc, %length
|
|
||||||
br i1 %exit.pred, label %loop, label %abort.loopexit
|
|
||||||
|
|
||||||
abort.loopexit:
|
|
||||||
br label %abort
|
|
||||||
|
|
||||||
abort:
|
|
||||||
ret i1 false
|
|
||||||
|
|
||||||
oob:
|
|
||||||
tail call void @abort()
|
|
||||||
ret i1 false
|
|
||||||
}
|
|
||||||
|
|
||||||
!0 = metadata !{i32 0, i32 100}
|
|
@ -67,7 +67,8 @@ for.end:
|
|||||||
define void @test2([8 x i8]* %a, i8* %b, i8 %limit) {
|
define void @test2([8 x i8]* %a, i8* %b, i8 %limit) {
|
||||||
entry:
|
entry:
|
||||||
%conv = zext i8 %limit to i32
|
%conv = zext i8 %limit to i32
|
||||||
br i1 undef, label %for.cond1.preheader, label %for.cond1.preheader.us
|
%cmp23 = icmp eq i8 %limit, 0
|
||||||
|
br i1 %cmp23, label %for.cond1.preheader, label %for.cond1.preheader.us
|
||||||
|
|
||||||
for.cond1.preheader.us:
|
for.cond1.preheader.us:
|
||||||
%storemerge5.us = phi i32 [ 0, %entry ], [ %inc14.us, %for.inc13.us ]
|
%storemerge5.us = phi i32 [ 0, %entry ], [ %inc14.us, %for.inc13.us ]
|
||||||
|
Loading…
Reference in New Issue
Block a user