partially fix https://github.com/llvm/llvm-project/issues/62441
the ugt/uge and sgt/sge icmp is not fold as isImpliedCondOperands only handles less cases
alive2 proof: https://alive2.llvm.org/ce/z/jLFDAv and https://alive2.llvm.org/ce/z/Z8idUd
Differential D149510
[ValueTracking] add UGT/UGE and SGT/SGE in `isImpliedCondOperands` floatshadow on Apr 28 2023, 11:29 PM. Authored by
Details partially fix https://github.com/llvm/llvm-project/issues/62441 the ugt/uge and sgt/sge icmp is not fold as isImpliedCondOperands only handles less cases alive2 proof: https://alive2.llvm.org/ce/z/jLFDAv and https://alive2.llvm.org/ce/z/Z8idUd
Diff Detail Event Timeline
Comment Actions LGTM. I'm not a maintainer to please wait a day or so to push so other have a chance to see. Comment Actions Thanks. I am not sure why isImpliedCondOperands handles less case only. Do we expect instcombine will canonicalize this? Comment Actions I'm not really sure. I think probably alot of the patterns are scattered around instcombine + instsimplify but Maybe @nikic knows. Comment Actions The extension to isImpliedCondOperands seems pretty reasonable to me. However, I think we should also handle the sgt/sge case at the same time, otherwise we're still going to leave this incomplete. We can test this part using variations of the existing patterns in the test, e.g. https://alive2.llvm.org/ce/z/Z8idUd. The new check in isTruePredicate I'm somewhat skeptical about. It adds support for one special case, but there are many other cases where we could determine that the predicate is true. This is essentially what the purpose of simplifyICmpInst is, and which presumably would already handle this pattern. However, there are likely compile-time concerns with just calling into InstSimplify here. Comment Actions I'd like to split the patch into smaller pieces, and this revision for isImpliedCondOperands only. Comment Actions Could you please also add some negative tests, e.g. where for unsigned predicate the nuw is missing? To make sure the correct implication check is done. |