[llvm] [InstCombine] Canonicalize xor with disjoint ops to or disjoint (PR #133139)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 9 02:39:03 PDT 2025


dtcxzyw wrote:

> For my purposes, what is most beneficial is:
> 
> ```
> %i48 = and i32 %i28, 1
> %i.not2 = icmp eq i32 %i48, 0
> %i49 = and i32 %i28, 2
> %i50 = icmp eq i32 %i49, 0
> %i144 = select i1 %i.not2, i32 0, i32 72
> %i145 = select i1 %i50, i32 0, i32 144
> %i146 = or disjoint i32 %i144, %i145
> ```
> 
> ->
> 
> ```
> %temp = and i32 %i32, 3
> %146 = mul %temp, 72
> ```
> 
> Which I imagine produces better code even for hardwares which prefer icmp->select over mul.

https://alive2.llvm.org/ce/z/1kmtuR

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


More information about the llvm-commits mailing list