[llvm] [InstCombine] Fix fail to fold (A >> C1) Pred C2 if shr is used multple times #83430 (PR #83563)

via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 8 08:19:19 PST 2024


SahilPatidar wrote:

Throughout the code review, I noticed an issue caused by `%switch.i = icmp ult i1 %cmp4.i, true`. This part of the code checks `if (TrueVal == CmpLHS && FalseVal == CmpRHS)`, indicating a match that could be handled more effectively with a pattern-matching approach. For example, in the following code snippet:

```IR
  %cmp4.i = icmp sgt i64 %shr, 348731
  %switch.i = icmp ult i1 %cmp4.i, true
  %spec.select.i = select i1 %switch.i, i64 %shr, i64 348731
```
If we examine the value of `%cmp4.i`, we find that both branches have the same value. This suggests that we only need to handle the middle pattern. I just noticed this and I am not clear on how effective it could be. Could you please provide your insight on this?

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


More information about the llvm-commits mailing list