diff options
author | Léonard Oest O'Leary <lool45162@gmail.com> | 2023-11-12 11:53:53 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-13 00:53:53 +0800 |
commit | ff36411b23e55d71a45088c30540e228e9ca6973 (patch) | |
tree | 85954fd15b5bd9476cb57509920d299203983840 /llvm/lib/CodeGen/MachineBasicBlock.cpp | |
parent | d05bada59205b9bcf1195a6eac7e09b721e3b79b (diff) | |
download | llvm-ff36411b23e55d71a45088c30540e228e9ca6973.zip llvm-ff36411b23e55d71a45088c30540e228e9ca6973.tar.gz llvm-ff36411b23e55d71a45088c30540e228e9ca6973.tar.bz2 |
[InstCombine] Use zext's nneg flag for icmp folding (#70845)
This PR fixes https://github.com/llvm/llvm-project/issues/55013 : the
max intrinsics is not generated for this simple loop case :
https://godbolt.org/z/hxz1xhMPh. This is caused by a ICMP not being
folded into a select, thus not generating the max intrinsics.
For the story :
Since LLVM 14, SCCP pass got smarter by folding sext into zext for
positive ranges : https://reviews.llvm.org/D81756. After this change,
InstCombine was sometimes unable to fold ICMP correctly as both of the
arguments pointed to mismatched zext/sext. To fix this, @rotateright
implemented this fix : https://reviews.llvm.org/D124419 that tries to
resolve the mismatch by knowing if the argument of a zext is positive
(in which case, it is like a sext) by using ValueTracking, however
ValueTracking is not smart enough to infer that the value is positive in
some cases. Recently, @nikic implemented #67982 which keeps the
information that a zext is non-negative. This PR simply uses this
information to do the folding accordingly.
TLDR : This PR uses the recent nneg tag on zext to fold the icmp
accordingly in instcombine.
This PR also contains test cases for sext/zext folding with InstCombine
as well as a x86 regression tests for the max/min case.
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
0 files changed, 0 insertions, 0 deletions