[llvm] [SCEV] Distribute zext across (C + Rest) in LoopGuards rewriter (PR #210719)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 20 02:48:09 PDT 2026
================
@@ -16424,6 +16424,30 @@ const SCEV *ScalarEvolution::LoopGuards::rewrite(const SCEV *Expr) const {
Bitwidth = Bitwidth / 2;
}
+ // Pull a leading constant out of the zext:
+ // zext(C + X) -> zext(X) - zext(-C), if X >=u -C.
+ const SCEVAddExpr *Add;
+ const APInt *C;
+ if (match(Op, m_scev_Add(Add)) &&
----------------
fhahn wrote:
It should be enough to just run `opt -p loop-unroll` on the IR above, it should unroll on current `main` (https://llvm.godbolt.org/z/sY1ndfKj1) and fail to unroll with the current version of the patch I think
https://github.com/llvm/llvm-project/pull/210719
More information about the llvm-commits
mailing list