[llvm] [InstCombine] Allow min/max in constant BOp min/max folding (PR #142878)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 8 18:57:07 PDT 2025


dtcxzyw wrote:

> Unfortunately, there doesn't seem like there exists a simply way to know whether wrapping occurred when constant folding the binop. 

If you only care about scalar constants/splat vectors, just use `APInt::xxxx_ov`.

> In addition, I've observed some cases where multiple binops with constants get folded into a comparison preventing this optimization from occuring. Would it be alright to iteratively fold binops with constants until we reach the other value in the select or is this sort of thing too complex / potentially expensive for InstCombine?

Can you provide some examples?


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


More information about the llvm-commits mailing list