mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-27 14:34:58 +00:00
copyFastMathFlags utility and test case
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168943 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e8832680f8
commit
4b896dd613
@ -227,6 +227,9 @@ public:
|
|||||||
/// these flats.
|
/// these flats.
|
||||||
FastMathFlags getFastMathFlags() const;
|
FastMathFlags getFastMathFlags() const;
|
||||||
|
|
||||||
|
/// Copy I's fast-math flags
|
||||||
|
void copyFastMathFlags(const Instruction *I);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// hasMetadataHashEntry - Return true if we have an entry in the on-the-side
|
/// hasMetadataHashEntry - Return true if we have an entry in the on-the-side
|
||||||
/// metadata hash.
|
/// metadata hash.
|
||||||
|
@ -177,6 +177,12 @@ FastMathFlags Instruction::getFastMathFlags() const {
|
|||||||
return cast<FPMathOperator>(this)->getFastMathFlags();
|
return cast<FPMathOperator>(this)->getFastMathFlags();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Copy I's fast-math flags
|
||||||
|
void Instruction::copyFastMathFlags(const Instruction *I) {
|
||||||
|
setFastMathFlags(I->getFastMathFlags());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *Instruction::getOpcodeName(unsigned OpCode) {
|
const char *Instruction::getOpcodeName(unsigned OpCode) {
|
||||||
switch (OpCode) {
|
switch (OpCode) {
|
||||||
// Terminators
|
// Terminators
|
||||||
|
@ -164,6 +164,15 @@ TEST_F(IRBuilderTest, FastMathFlags) {
|
|||||||
FDiv = cast<Instruction>(F);
|
FDiv = cast<Instruction>(F);
|
||||||
EXPECT_TRUE(FDiv->hasAllowReciprocal());
|
EXPECT_TRUE(FDiv->hasAllowReciprocal());
|
||||||
|
|
||||||
|
Builder.clearFastMathFlags();
|
||||||
|
|
||||||
|
F = Builder.CreateFDiv(F, F);
|
||||||
|
ASSERT_TRUE(isa<Instruction>(F));
|
||||||
|
FDiv = cast<Instruction>(F);
|
||||||
|
EXPECT_FALSE(FDiv->getFastMathFlags().any());
|
||||||
|
FDiv->copyFastMathFlags(FAdd);
|
||||||
|
EXPECT_TRUE(FDiv->hasNoNaNs());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user