[PATCH] D69176: [IR] Reimplement FPMathOperator::classof as a whitelist.
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 18 08:57:04 PDT 2019
foad created this revision.
foad added reviewers: spatel, wristow, arsenm, hfinkel, aemerson, efriedma, cameron.mcinally, mcberg2017, jmolloy.
Herald added a subscriber: wdng.
Herald added a project: LLVM.
This makes it much easier to verify that the implementation matches the
documentation. It uncovered a bug in the unit tests where we were
accidentally setting fast math flags on a load instruction.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D69176
Files:
llvm/include/llvm/IR/Operator.h
llvm/unittests/IR/IRBuilderTest.cpp
Index: llvm/unittests/IR/IRBuilderTest.cpp
===================================================================
--- llvm/unittests/IR/IRBuilderTest.cpp
+++ llvm/unittests/IR/IRBuilderTest.cpp
@@ -376,7 +376,7 @@
ASSERT_FALSE(isa<BinaryOperator>(U));
// Test CreateFNegFMF(X)
- Instruction *I = cast<Instruction>(V);
+ Instruction *I = cast<Instruction>(U);
I->setHasNoSignedZeros(true);
I->setHasNoNaNs(true);
Value *VFMF = Builder.CreateFNegFMF(V, I);
Index: llvm/include/llvm/IR/Operator.h
===================================================================
--- llvm/include/llvm/IR/Operator.h
+++ llvm/include/llvm/IR/Operator.h
@@ -379,6 +379,12 @@
return false;
switch (Opcode) {
+ case Instruction::FNeg:
+ case Instruction::FAdd:
+ case Instruction::FSub:
+ case Instruction::FMul:
+ case Instruction::FDiv:
+ case Instruction::FRem:
// FIXME: To clean up and correct the semantics of fast-math-flags, FCmp
// should not be treated as a math op, but the other opcodes should.
// This would make things consistent with Select/PHI (FP value type
@@ -386,13 +392,12 @@
// having fast-math-flags).
case Instruction::FCmp:
return true;
- // non math FP Operators (no FMF)
- case Instruction::ExtractElement:
- case Instruction::ShuffleVector:
- case Instruction::InsertElement:
- return false;
- default:
+ case Instruction::PHI:
+ case Instruction::Select:
+ case Instruction::Call:
return V->getType()->isFPOrFPVectorTy();
+ default:
+ return false;
}
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69176.225645.patch
Type: text/x-patch
Size: 1617 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191018/ed772972/attachment.bin>
More information about the llvm-commits
mailing list