forked from OSchip/llvm-project
Added unit tests to check supported rounding modes
Also added fixed misspelled metadata name. Differential Revision: https://reviews.llvm.org/D66073 llvm-svn: 368650
This commit is contained in:
parent
892cdc73be
commit
2a09b9acfb
|
@ -143,7 +143,7 @@ ConstrainedFPIntrinsic::RoundingModeToStr(RoundingMode UseRounding) {
|
|||
RoundingStr = "round.upward";
|
||||
break;
|
||||
case ConstrainedFPIntrinsic::rmTowardZero:
|
||||
RoundingStr = "round.tozero";
|
||||
RoundingStr = "round.towardzero";
|
||||
break;
|
||||
}
|
||||
return RoundingStr;
|
||||
|
|
|
@ -187,6 +187,34 @@ TEST_F(IRBuilderTest, ConstrainedFP) {
|
|||
ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebIgnore);
|
||||
ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmUpward);
|
||||
|
||||
Builder.setDefaultConstrainedExcept(ConstrainedFPIntrinsic::ebIgnore);
|
||||
Builder.setDefaultConstrainedRounding(ConstrainedFPIntrinsic::rmToNearest);
|
||||
V = Builder.CreateFAdd(V, V);
|
||||
CII = cast<ConstrainedFPIntrinsic>(V);
|
||||
ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebIgnore);
|
||||
ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmToNearest);
|
||||
|
||||
Builder.setDefaultConstrainedExcept(ConstrainedFPIntrinsic::ebMayTrap);
|
||||
Builder.setDefaultConstrainedRounding(ConstrainedFPIntrinsic::rmDownward);
|
||||
V = Builder.CreateFAdd(V, V);
|
||||
CII = cast<ConstrainedFPIntrinsic>(V);
|
||||
ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebMayTrap);
|
||||
ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmDownward);
|
||||
|
||||
Builder.setDefaultConstrainedExcept(ConstrainedFPIntrinsic::ebStrict);
|
||||
Builder.setDefaultConstrainedRounding(ConstrainedFPIntrinsic::rmTowardZero);
|
||||
V = Builder.CreateFAdd(V, V);
|
||||
CII = cast<ConstrainedFPIntrinsic>(V);
|
||||
ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebStrict);
|
||||
ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmTowardZero);
|
||||
|
||||
Builder.setDefaultConstrainedExcept(ConstrainedFPIntrinsic::ebIgnore);
|
||||
Builder.setDefaultConstrainedRounding(ConstrainedFPIntrinsic::rmDynamic);
|
||||
V = Builder.CreateFAdd(V, V);
|
||||
CII = cast<ConstrainedFPIntrinsic>(V);
|
||||
ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebIgnore);
|
||||
ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmDynamic);
|
||||
|
||||
// Now override the defaults.
|
||||
Call = Builder.CreateConstrainedFPBinOp(
|
||||
Intrinsic::experimental_constrained_fadd, V, V, nullptr, "", nullptr,
|
||||
|
|
Loading…
Reference in New Issue