[llvm] ValueTracking: teach implied-cond about samesign (PR #116614)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 18 07:09:47 PST 2024


nikic wrote:

You generally can't assume that *both* icmps will get the same canonicalization. Consider code structure like this:

```
if (a sgt b) {
  if (a sge 0 && b sge 0) {
    if (a sge b) { // canonicalized to a samesign uge b
    }
  }
}
```

The first comparison can't be canonicalized, because the preconditions for that don't hold, so we only canonicalize the second one. And then we'd want to undo that one to a sge b to make the signedness of the predicates match, and then we have the implication that a sgt b => a sge b.

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


More information about the llvm-commits mailing list