llvm.org GIT mirror llvm / 0a406ae
Fix PR 7087, and probably other things, by extending getConstantFP to accept the two supported long double target types. This was not the original intent, but there are other places that assume this works and it's easy enough to do. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103299 91177308-0d34-0410-b5e6-96231b3b80d8 Dale Johannesen 9 years ago
3 changed file(s) with 40 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
333333 SDValue getTargetConstant(const ConstantInt &Val, EVT VT) {
334334 return getConstant(Val, VT, true);
335335 }
336 // The forms below that take a double should only be used for simple
337 // constants that can be exactly represented in VT. No checks are made.
336338 SDValue getConstantFP(double Val, EVT VT, bool isTarget = false);
337339 SDValue getConstantFP(const APFloat& Val, EVT VT, bool isTarget = false);
338340 SDValue getConstantFP(const ConstantFP &CF, EVT VT, bool isTarget = false);
963963 EVT EltVT = VT.getScalarType();
964964 if (EltVT==MVT::f32)
965965 return getConstantFP(APFloat((float)Val), VT, isTarget);
966 else
966 else if (EltVT==MVT::f64)
967967 return getConstantFP(APFloat(Val), VT, isTarget);
968 else if (EltVT==MVT::f80 || EltVT==MVT::f128) {
969 bool ignored;
970 APFloat apf = APFloat(Val);
971 apf.convert(*EVTToAPFloatSemantics(EltVT), APFloat::rmNearestTiesToEven,
972 &ignored);
973 return getConstantFP(apf, VT, isTarget);
974 } else {
975 assert(0 && "Unsupported type in getConstantFP");
976 return SDValue();
977 }
968978 }
969979
970980 SDValue SelectionDAG::getGlobalAddress(const GlobalValue *GV,
0 ; RUN: llc < %s -mtriple=x86_64-apple-darwin11
1 ; PR 7087 - used to crash
2
3 define i32 @main() ssp {
4 entry:
5 %retval = alloca i32, align 4 ; [#uses=2]
6 %r = alloca i32, align 4 ; [#uses=2]
7 store i32 0, i32* %retval
8 %tmp = call x86_fp80 @llvm.powi.f80(x86_fp80 0xK3FFF8000000000000000, i32 -64) ; [#uses=1]
9 %conv = fptosi x86_fp80 %tmp to i32 ; [#uses=1]
10 store i32 %conv, i32* %r
11 %tmp1 = load i32* %r ; [#uses=1]
12 %tobool = icmp ne i32 %tmp1, 0 ; [#uses=1]
13 br i1 %tobool, label %if.then, label %if.end
14
15 if.then: ; preds = %entry
16 call void @_Z1fv()
17 br label %if.end
18
19 if.end: ; preds = %if.then, %entry
20 %0 = load i32* %retval ; [#uses=1]
21 ret i32 %0
22 }
23
24 declare x86_fp80 @llvm.powi.f80(x86_fp80, i32) nounwind readonly
25
26 declare void @_Z1fv()