1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

[IR] Reimplement FPMathOperator::classof as a whitelist.

Summary:
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.

Reviewers: spatel, wristow, arsenm, hfinkel, aemerson, efriedma, cameron.mcinally, mcberg2017, jmolloy

Subscribers: wdng, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D69176

llvm-svn: 375252
This commit is contained in:
Jay Foad 2019-10-18 16:16:36 +00:00
parent ee4f590a23
commit 496ec33cdb
2 changed files with 12 additions and 7 deletions

View File

@ -379,6 +379,12 @@ public:
return false; return false;
switch (Opcode) { 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 // 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. // should not be treated as a math op, but the other opcodes should.
// This would make things consistent with Select/PHI (FP value type // This would make things consistent with Select/PHI (FP value type
@ -386,13 +392,12 @@ public:
// having fast-math-flags). // having fast-math-flags).
case Instruction::FCmp: case Instruction::FCmp:
return true; return true;
// non math FP Operators (no FMF) case Instruction::PHI:
case Instruction::ExtractElement: case Instruction::Select:
case Instruction::ShuffleVector: case Instruction::Call:
case Instruction::InsertElement:
return false;
default:
return V->getType()->isFPOrFPVectorTy(); return V->getType()->isFPOrFPVectorTy();
default:
return false;
} }
} }
}; };

View File

@ -376,7 +376,7 @@ TEST_F(IRBuilderTest, UnaryOperators) {
ASSERT_FALSE(isa<BinaryOperator>(U)); ASSERT_FALSE(isa<BinaryOperator>(U));
// Test CreateFNegFMF(X) // Test CreateFNegFMF(X)
Instruction *I = cast<Instruction>(V); Instruction *I = cast<Instruction>(U);
I->setHasNoSignedZeros(true); I->setHasNoSignedZeros(true);
I->setHasNoNaNs(true); I->setHasNoNaNs(true);
Value *VFMF = Builder.CreateFNegFMF(V, I); Value *VFMF = Builder.CreateFNegFMF(V, I);