-
Notifications
You must be signed in to change notification settings - Fork 13.6k
SCEV: thread samesign in isBasicBlockEntryGuardedByCond (NFC) #125840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
isBasicBlockEntryGuardedByCond inadvertedenly drops samesign information when calling ICmpInst::getNonStrictPredicate. Fix this.
@llvm/pr-subscribers-llvm-analysis @llvm/pr-subscribers-llvm-ir Author: Ramkumar Ramachandra (artagnon) ChangesisBasicBlockEntryGuardedByCond inadvertedenly drops samesign information when calling ICmpInst::getNonStrictPredicate. Fix this. Full diff: https://github.com/llvm/llvm-project/pull/125840.diff 2 Files Affected:
diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h
index 9a41971b63373c..a1f964352207f7 100644
--- a/llvm/include/llvm/IR/Instructions.h
+++ b/llvm/include/llvm/IR/Instructions.h
@@ -1231,6 +1231,18 @@ class ICmpInst: public CmpInst {
return getSwappedCmpPredicate(getCmpPredicate());
}
+ /// @returns the non-strict predicate along with samesign information: static
+ /// variant.
+ static CmpPredicate getNonStrictCmpPredicate(CmpPredicate Pred) {
+ return {getNonStrictPredicate(Pred), Pred.hasSameSign()};
+ }
+
+ /// For example, SGT -> SGE, SLT -> SLE, ULT -> ULE, UGT -> UGE.
+ /// @returns the non-strict predicate along with samesign information.
+ Predicate getNonStrictCmpPredicate() const {
+ return getNonStrictCmpPredicate(getCmpPredicate());
+ }
+
/// For example, EQ->EQ, SLE->SLE, UGT->SGT, etc.
/// @returns the predicate that would be the result if the operand were
/// regarded as signed.
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 0d7bbe3f996408..1673dc3acd2a12 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -11632,8 +11632,9 @@ bool ScalarEvolution::isBasicBlockEntryGuardedByCond(const BasicBlock *BB,
// non-strict comparison is known from ranges and non-equality is known from
// dominating predicates. If we are proving strict comparison, we always try
// to prove non-equality and non-strict comparison separately.
- auto NonStrictPredicate = ICmpInst::getNonStrictPredicate(Pred);
- const bool ProvingStrictComparison = (Pred != NonStrictPredicate);
+ CmpPredicate NonStrictPredicate = ICmpInst::getNonStrictCmpPredicate(Pred);
+ const bool ProvingStrictComparison =
+ (Pred != static_cast<CmpInst::Predicate>(NonStrictPredicate));
bool ProvedNonStrictComparison = false;
bool ProvedNonEquality = false;
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/73/builds/12973 Here is the relevant piece of the build log for the reference
|
Looks like this broke check-clang on mac: http://45.33.8.238/macm1/100556/step_6.txt (Linux seems happy.) Please take a look and revert for now if it takes a while to fix. |
@nico Pretty sure I see spurious failures of that test on aarch64 all the time. Does it fail persistently after this change? |
You're right, it cycled green on the next build (http://45.33.8.238/macm1/100557/summary.html). If this is a known flake:
|
Please mark it as UNSUPPORTED and file an issue. A quick search didn't pull anything up. |
…25840) isBasicBlockEntryGuardedByCond inadvertedenly drops samesign information when calling ICmpInst::getNonStrictPredicate. Fix this.
See llvm#126619 and discussion on llvm#125840
See llvm#126619 and discussion on llvm#125840
See llvm#126619 and discussion on llvm#125840
isBasicBlockEntryGuardedByCond inadvertedenly drops samesign information when calling ICmpInst::getNonStrictPredicate. Fix this.