[llvm] [InstCombine][Docs] Update InstCombine contributor guide (PR #144228)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 15 04:33:57 PDT 2025
================
@@ -531,6 +551,19 @@ need to add a one-use check for the inner instruction.
One-use checks can be performed using the `m_OneUse()` matcher, or the
`V->hasOneUse()` method.
+### Flag handling
+
+When possible, propagate poison-generating flags like `nuw` and `nsw` since they may be
+hard to salvage later. If it is not free (e.g. requires additional complexity like `willNotOverflow`
+or KnownBits queries), don't do that.
+
+Be careful with in-place operand/predicate changes, as poison-generating flags may not be valid for new
+operands. It is recommended to create a new instruction with carefully handling of flags. If not
+applicable, call `Instruction::dropPoisonGeneratingFlags()` to clear flags in a conservative manner.
+
+Do not rely on fcmp's `nsz` flag to perform optimizations. It is meaningless for fcmp so it should not affect
+the optimization.
----------------
dtcxzyw wrote:
0.0 and -0.0 are considered equal, even if nsz is absent.
https://github.com/llvm/llvm-project/pull/144228
More information about the llvm-commits
mailing list