[llvm] [InstCombine] fold `(icmp eq/ne (or disjoint x, C0), C1)` -> `(icmp eq/ne x, C0^C1)` (PR #87734)

via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 7 11:06:50 PDT 2024


goldsteinn wrote:

> If we phrase `(or disjoint x, C0) == C1` as `x + C0 == C1`, this fold is just like `x + C0 == C1` -> `X == C1 - C0`: https://alive2.llvm.org/ce/z/aRk27g Or we should put it in
> 
> https://github.com/llvm/llvm-project/blob/c91254db1dcace869f4d3f1ac659bdd7700a1459/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp#L3441
> 
> , so that we could handle it easier?

I don't think so for two reasons.
1) This only count's for `disjoint or` so we need special logic for fallthrough which I'm not sure would be simpler to implement.
2) the add case avoid multi-use. This is pretty specific to add b.c folding for multi-use messes up some loop optimizations. We don't want/need the same restriction for `disjoint or`.

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


More information about the llvm-commits mailing list