[llvm] [InstCombine] Fold max(max(x, c1) << c2, c3) —> max(x << c2, c3) when c3 >= c1 * 2 ^ c2 (PR #140526)

via llvm-commits llvm-commits at lists.llvm.org
Tue May 20 01:15:10 PDT 2025


Charukesh827 wrote:

made most of suggested changes. Only thing is i didn't understand what has to be done for generalizing div, Please help me with that. 

about the suggestion you gave:

"Solution1: Canonicalize max(x << shamt, c << shamt) into max(x, c) << shamt: https://alive2.llvm.org/ce/z/mQEDAQ
We already did similar things in moveAddAfterMinMax .

Solution2: Generalize to fold max(max(x, c1) binop c2, c3) —> max(x binop c2, c3)."

solution 1 was already available so i didn't make it. I only concentrated on solution 2

![image](https://github.com/user-attachments/assets/f0760e29-f8ce-4549-82b4-d8a2a2daeac7)

Alive2: https://alive2.llvm.org/ce/z/on2tJE

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


More information about the llvm-commits mailing list