[InstCombine] reorder icmp with offset folds for better results
authorSanjay Patel <spatel@rotateright.com>
Wed, 14 Jul 2021 15:57:36 +0000 (11:57 -0400)
committerSanjay Patel <spatel@rotateright.com>
Wed, 14 Jul 2021 16:12:05 +0000 (12:12 -0400)
commitca6e117d86341682e20025f204294c0ca78c355e
tree74d40413959f5535764358e928e319b58cc8f4f5
parentb155c871f2e21beed45d15a25f7c84fb4f0c1d93
[InstCombine] reorder icmp with offset folds for better results

This set of folds was added recently with:
c7b658aeb526
0c400e895306
40b752d28d95

...and I noted that this wasn't likely to fire in code derived
from C/C++ source because of nsw in particular. But I didn't
notice that I had placed the code above the no-wrap block
of transforms.

This is likely the cause of regressions noted from the previous
commit because -- as shown in the test diffs -- we may have
transformed into a compare with an arbitrary constant rather
than a simpler signbit test.
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/icmp-add.ll