[llvm] [InstCombine] Fold `switch(rol(x, C1)) case C2:` to `switch(x) case rol(C2, -C1):` (PR #86307)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 22 10:52:12 PDT 2024


dtcxzyw wrote:

> > This change looks fine, although it would be nice if we had some helper generically detecting if an op is reversable so we could generalize all these cases.
> 
> Would also be useful for things like `icmp eq/ne X, C`

It has been supported.
https://github.com/llvm/llvm-project/blob/bbcfe6f4311af8cf6095a5bc5937fa68a87b4289/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp#L3621-L3633

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


More information about the llvm-commits mailing list