[PATCH] D82721: [ScalarEvolution] createSCEV(): MatchBinaryOp(): recognize `urem` disguised as an `srem`

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 29 11:54:18 PDT 2020


efriedma added a comment.

Not sure I understand what benefit you're expecting on the linked testcase.



================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:4346
+  case Instruction::SRem: {
+    // If the sign bits of both operands are zero (i.e. we can prove they are
+    // unsigned inputs), this is just an urem.
----------------
Can we stick this code into ScalarEvolution::createSCEV directly?  I don't think any of the other users of MatchBinaryOp care whether they get a urem or an srem.

Can we use the same code for sdiv?


================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:4352
+                               dyn_cast<Instruction>(Op), &DT);
+    };
+    if (IsNonNegative(Op->getOperand(1)) && IsNonNegative(Op->getOperand(0))) {
----------------
Can we not use isKnownNonNegative?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82721/new/

https://reviews.llvm.org/D82721





More information about the llvm-commits mailing list