[all-commits] [llvm/llvm-project] d74d84: [SECV] Try to push the op into ZExt: A + zext (-A ...

Florian Hahn via All-commits all-commits at lists.llvm.org
Wed Jul 30 13:11:20 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d74d841b65dc5ecc1adb87f94ee5c8073984e130
      https://github.com/llvm/llvm-project/commit/d74d841b65dc5ecc1adb87f94ee5c8073984e130
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2025-07-30 (Wed, 30 Jul 2025)

  Changed paths:
    M llvm/lib/Analysis/ScalarEvolution.cpp
    M llvm/test/Analysis/ScalarEvolution/zext-add.ll
    M llvm/test/Transforms/IndVarSimplify/AArch64/fold-ext-add.ll
    M llvm/test/Transforms/IndVarSimplify/zext-nuw.ll

  Log Message:
  -----------
  [SECV] Try to push the op into ZExt: A + zext (-A + B) -> zext (B) (#151227)

Try to push the constant operand into a ZExt:
A + zext (-A + B) -> zext (B), if trunc (A) + -A + B does not
unsigned-wrap.

The actual code supports ZExts with arbitrary number of arguments, hence
the getAddExpr in the return.

This helps SCEV reasoning in some cases, commonly when adding an offset
to a zero-extended SCEV that subtracts the same offset.

Note that this is restricted to cases where we can fold away an operand
of the inner Add. This is needed to avoid bad interactions with patterns
when forming ZExts, which try to push to ZExt to add operands.

https://alive2.llvm.org/ce/z/q7d303

PR: https://github.com/llvm/llvm-project/pull/151227



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list