[llvm] [SCEVExpander] Support hoisting udiv X, Y where Y is non-zero (PR #96102)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 19 17:55:24 PDT 2024
================
@@ -1470,12 +1470,11 @@ Value *SCEVExpander::expand(const SCEV *S) {
// We can move insertion point only if there is no div or rem operations
// otherwise we are risky to move it over the check for zero denominator.
- auto SafeToHoist = [](const SCEV *S) {
- return !SCEVExprContains(S, [](const SCEV *S) {
+ auto SafeToHoist = [&](const SCEV *S) {
+ return !SCEVExprContains(S, [&](const SCEV *S) {
if (const auto *D = dyn_cast<SCEVUDivExpr>(S)) {
- if (const auto *SC = dyn_cast<SCEVConstant>(D->getRHS()))
- // Division by non-zero constants can be hoisted.
- return SC->getValue()->isZero();
+ if (SE.isKnownNonZero(D->getRHS()))
----------------
efriedma-quic wrote:
Do you also need to prove it's not poison?
https://github.com/llvm/llvm-project/pull/96102
More information about the llvm-commits
mailing list