[PATCH] D44550: [InstCombine] canonicalize fcmp+select to fabs
Mikhail Dvoretckii via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 16 06:12:45 PDT 2018
mike.dvoretsky added inline comments.
================
Comment at: lib/Transforms/InstCombine/InstCombineSelect.cpp:1577
+ FCmpInst::Predicate Pred = FCI->getPredicate();
+ if (match(FCI->getOperand(1), m_AnyZeroFP())) {
+ // (X <= +/-0.0) ? (0.0 - X) : X --> fabs(X)
----------------
I think there should be an nnan check here. The patterns in DAGCombiner check it implicitly by requiring condition codes that only occur in FP math under nnan, but this code currently doesn't require that, and all of the patterns would direct NaNs of either sign to the same option, creating the same kind of issue as the current patterns have with zero signs (and 0.0 - NaN shouldn't even do anything).
https://reviews.llvm.org/D44550
More information about the llvm-commits
mailing list