From 88f2d6c167a575e5d9c62ecb211ff4d825b09ed3 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Tue, 25 Nov 2008 19:00:29 +0000 Subject: [PATCH] convertToSignExtendedInteger should return opInvalidOp instead of asserting if sematics of float does not allow arithmetics. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60042 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/APFloat.cpp | 8 +++++++- .../IndVarsSimplify/2008-11-25-APFloatAssert.ll | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 test/Transforms/IndVarsSimplify/2008-11-25-APFloatAssert.ll diff --git a/lib/Support/APFloat.cpp b/lib/Support/APFloat.cpp index a65e55afb56..128fee4f01f 100644 --- a/lib/Support/APFloat.cpp +++ b/lib/Support/APFloat.cpp @@ -117,6 +117,11 @@ namespace { && "Compile-time arithmetic does not support these semantics"); } + static inline bool + isArithmeticOk(const llvm::fltSemantics &semantics) { + return semantics.arithmeticOK; + } + /* Return the value of a decimal exponent of the form [+-]ddddddd. @@ -1787,7 +1792,8 @@ APFloat::convertToSignExtendedInteger(integerPart *parts, unsigned int width, const integerPart *src; unsigned int dstPartsCount, truncatedBits; - assertArithmeticOK(*semantics); + if (!isArithmeticOk(*semantics)) + return opInvalidOp; *isExact = false; diff --git a/test/Transforms/IndVarsSimplify/2008-11-25-APFloatAssert.ll b/test/Transforms/IndVarsSimplify/2008-11-25-APFloatAssert.ll new file mode 100644 index 00000000000..9fd0eb9e65a --- /dev/null +++ b/test/Transforms/IndVarsSimplify/2008-11-25-APFloatAssert.ll @@ -0,0 +1,11 @@ +; RUN: llvm-as < %s | opt -indvars + +define void @t() nounwind { +entry: + br label %bb23.i91 + +bb23.i91: ; preds = %bb23.i91, %entry + %result.0.i89 = phi ppc_fp128 [ 0xM00000000000000000000000000000000, %entry ], [ %0, %bb23.i91 ] ; [#uses=2] + %0 = mul ppc_fp128 %result.0.i89, %result.0.i89 ; [#uses=1] + br label %bb23.i91 +} -- 2.34.1