[llvm] [InstCombine] Remove the canonicalization of `trunc` to `i1` (PR #84628)

via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 10 12:44:17 PDT 2024


goldsteinn wrote:

> After examining the code, I found that those folds are not the key problem. In fact, the removal of canonicalization affects two folds in that regression:
> 
> ```
> ((C1 << X) & C2) != 0   ->  X < (Log2(C2+C1) - Log2(C1))           (foldICmpUsingKnownBits)
> ((C1 << X) >> C2) & C3  ->  X == (cttz(C3)+C2-cttz(C1)) ? C3 : 0   (visitAnd)
> ```
> 
> Making those folds inside `foldAndOrOfICmps` accept `trunc` seems provide no help to these two folds, unless a more thorough decomposition is performed. So I just copied two folds to `visitTrunc`.

Seems reasonable, not sure if this canonicalization is relied on elsewhere thought.

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


More information about the llvm-commits mailing list