[PATCH] D152278: [SCEV] Compute SCEV for ashr(add(shl(x, n), c), m) instr triplet

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 8 21:52:22 PDT 2023


efriedma added inline comments.


================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:7893
+          // type, so create a new Constant with type same as TruncTy
+          int64_t AddOperand = AddOperandCI->getSExtValue();
+          const SCEV *AddConstant = getConstant(TruncTy, AddOperand >> AShrAmt);
----------------
vedant-amd wrote:
> efriedma wrote:
> > Is there some reason to expect that "c" fits into an int64_t?
> Right, I need to add a check like this I guess ?
> 
> ```
>       if (CI->getValue().uge(BitWidth))
> 
> ```
That doesn't look like the right check.

If it were necessary, you could use isIntN or something like that.  But you should just be able to just do the math in APInt: `AddOperandCI->getValue().ashr(AShrAmt)` or something like that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152278



More information about the llvm-commits mailing list