llvm-project/llvm/test/Transforms/ConstraintElimination
Florian Hahn daf0182277
[ConstraintElim] Apply add with neg constant first during decomp. (#164791)
We have dedicated decomposition logic for (add %x, -C), but if we have
(add nsw %x, -C) we will first apply the generic logic for NSWAdd, which
gives worse results for negative constants in practice.

Update the code to first apply the pattern with negative constants.

Helps to remove a number of runtime checks in practice:
https://github.com/dtcxzyw/llvm-opt-benchmark/pull/2968

Alive2 proofs for the test changes: https://alive2.llvm.org/ce/z/JfR2Ma

PR: https://github.com/llvm/llvm-project/pull/164791
2025-10-23 12:50:12 +01:00
..