[PATCH] D47965: [SCEV] Canonicalize "A /u C1 /u C2" to "A /u (C1*C2)".
Sanjoy Das via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 8 19:32:39 PDT 2018
sanjoy accepted this revision.
sanjoy added inline comments.
This revision is now accepted and ready to land.
================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:3072
+ if (const SCEVUDivExpr *OtherDiv = dyn_cast<SCEVUDivExpr>(LHS)) {
+ if (auto DivisorConstant = dyn_cast<SCEVConstant>(OtherDiv->getRHS())) {
+ bool Overflow = false;
----------------
LLVM usually prefers `auto *` for pointers.
================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:3076
+ DivisorConstant->getAPInt().umul_ov(RHSC->getAPInt(), Overflow);
+ if (!Overflow) {
+ return getUDivExpr(OtherDiv->getLHS(), getConstant(NewRHS));
----------------
If it does overflow then we can just return `0` here right?
[Up to you if you want to handle that case or just add a TODO]
https://reviews.llvm.org/D47965
More information about the llvm-commits
mailing list