[llvm] [LV] Fix handleFirstArgMinOrMax to use 0 as identity element for UMax/SMax (PR #192054)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 16 05:01:21 PDT 2026


https://github.com/fhahn commented:

> However, the issue is more subtle: the guard AlwaysFalse = icmp eq MinOrMaxResult, MinOrMaxPhiR->getStartValue() is incorrect (see the other comment

Could you point me to that comment?

> Additionally, using PoisonValue as the initial value for a UMax/SMax reduction is semantically problematic - while the poison may not leak in the current implementation, it creates fragile code that depends on specific optimization patterns. Using 0 (the identity element for UMax/SMax) is the correct approach and avoids these issues entirely.

Could you elaborate more on what fragile pattern you are thinking about? AFAICT min/max for poison in LLVM IR is well defined.



https://github.com/llvm/llvm-project/pull/192054


More information about the llvm-commits mailing list