[PATCH] D121323: [InstCombine] Fold select based logic of fcmps with same operands when FMF is present.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 9 11:58:55 PST 2022
craig.topper created this revision.
craig.topper added reviewers: spatel, lebedev.ri, nikic, nlopes.
Herald added a subscriber: hiraditya.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added a project: LLVM.
If we have a logical and/or in select form and the true/false operand
is an fcmp with poison generating FMF, we won't be able to fold it
to an and/or instruction. This prevents us from optimizing the case
where it is a logical operation of two fcmps with identical operands.
This patch adds explicit checks for this case that doesn't rely on
converting to and/or to do the optimization. It reuses the existing
foldLogicOfFCmps, but adds a new flag to disable the other combine
that is inside that function.
FMF flags from the two FCmps are intersected using the logic added in
D121243 <https://reviews.llvm.org/D121243>. The FIXME has been updated to indicate that we can only use
a union for the non-select form.
This allows us to optimize cases like this from compare-fp-3.c in the
gcc torture suite with fast math.
void
test1 (float x, float y)
{
if ((x==y) && (x!=y))
link_error0();
}
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D121323
Files:
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/lib/Transforms/InstCombine/InstCombineInternal.h
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/test/Transforms/InstCombine/and-fcmp.ll
llvm/test/Transforms/InstCombine/or-fcmp.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121323.414181.patch
Type: text/x-patch
Size: 145101 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220309/7d9fab85/attachment-0001.bin>
More information about the llvm-commits
mailing list