[PATCH] D51216: Fix IRBuilder.CreateFCmp(X, X) misfolding
Andrew Scheidecker via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 19 15:38:55 PDT 2018
AndrewScheidecker added a comment.
> Hm, can we use fast-math flags here? Namely, `nnan`.
It's possible, but not a trivial change. I added a nullable const FastMathFlags* parameter to:
- evaluateFCmpRelation and ConstantFoldCompareInstruction
- ConstantExpr::getCompare and ConstantExpr::getFCmp
- TargetFolder::CreateFCmp, ConstantFolder::CreateFCmp, and NoFolder
Then, IRBuilder::CreateFCmp can pass its current FastMathFlags through to the constant folder. Most places in LLVM I saw that were calling IRBuilder::CreateFCmp seemed to be setting the FastMathFlags, but there were a few transforms that didn't seem to be propagating them through:
- foldLogicOfFCmps in InstCombineAndOrXor.cpp
- foldVectorCmp in InstCombineCompares.cpp
- foldOpIntoPhi in InstructionCombining.cpp (line 993)
- FCmpSplitter in Scalarizer.cpp
- vectorizeTree(TreeEntry*) in SLPVectorizer.cpp (line 3223)
I stopped trying to propagate the fast-math flags dependency out when I got to ConstantFolding.cpp (i.e. the constant folding pass rather than the IRBuilder constant folder). Since ConstantExpr doesn't have fast-math flags, there isn't a way to transmit the fast-math flags from whatever produced the ConstantExpr.
So I think it's doable, but beyond the scope of this change.
Repository:
rL LLVM
https://reviews.llvm.org/D51216
More information about the llvm-commits
mailing list