[all-commits] [llvm/llvm-project] ff3641: [InstCombine] Use zext's nneg flag for icmp foldin...
leo-ard via All-commits
all-commits at lists.llvm.org
Sun Nov 12 08:54:06 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: ff36411b23e55d71a45088c30540e228e9ca6973
https://github.com/llvm/llvm-project/commit/ff36411b23e55d71a45088c30540e228e9ca6973
Author: LĂ©onard Oest O'Leary <lool45162 at gmail.com>
Date: 2023-11-13 (Mon, 13 Nov 2023)
Changed paths:
M llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
M llvm/test/Transforms/InstCombine/icmp-ext-ext.ll
A llvm/test/Transforms/PhaseOrdering/min_max_loop.ll
Log Message:
-----------
[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.
More information about the All-commits
mailing list