[PATCH] D89821: [SCEV] Match 'zext (trunc A to iB) to iY' as URem.
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 20 14:02:38 PDT 2020
lebedev.ri added a comment.
I would expect that you should be able to showcase the effect with `opt -analyze -scalar-evolution`-based test:
https://godbolt.org/z/xddz8d (because there's `zext(A % B) --> zext(A) % zext(B)` `matchURem()`-driven fold)
================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:12757
// 4, A / B becomes X / 8).
bool ScalarEvolution::matchURem(const SCEV *Expr, const SCEV *&LHS,
const SCEV *&RHS) {
----------------
What if `Expr` isn't an `zext` itself, but it is used by zext (which is the case in the single user of this method)?
================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:12760-12761
+ // Try to match 'zext (trunc A to iB) to iY', which is used
+ // for URem with constant power-of-2 second operands. Make sure the size of
+ // the operand A matches the size of the whole expressions.
+ if (const auto *ZExt = dyn_cast<SCEVZeroExtendExpr>(Expr)) {
----------------
What if we had `zext(zext(trunc))`, so we end up with a wider type than A was?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D89821/new/
https://reviews.llvm.org/D89821
More information about the llvm-commits
mailing list