llvm.org GIT mirror llvm / 2f91f30
Fix PR 4057, a crash doing float->char const folding. This particular one is undefined behavior (although this isn't related to the crash), so it will no longer do it at compile time, which seems better. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69990 91177308-0d34-0410-b5e6-96231b3b80d8 Dale Johannesen 11 years ago
2 changed file(s) with 22 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
21962196 }
21972197 case ISD::FP_TO_SINT:
21982198 case ISD::FP_TO_UINT: {
2199 integerPart x;
2199 integerPart x[2];
22002200 bool ignored;
22012201 assert(integerPartWidth >= 64);
22022202 // FIXME need to be more flexible about rounding mode.
2203 APFloat::opStatus s = V.convertToInteger(&x, 64U,
2203 APFloat::opStatus s = V.convertToInteger(x, VT.getSizeInBits(),
22042204 Opcode==ISD::FP_TO_SINT,
22052205 APFloat::rmTowardZero, &ignored);
22062206 if (s==APFloat::opInvalidOp) // inexact is OK, in fact usual
22072207 break;
2208 return getConstant(x, VT);
2208 APInt api(VT.getSizeInBits(), 2, x);
2209 return getConstant(api, VT);
22092210 }
22102211 case ISD::BIT_CONVERT:
22112212 if (VT == MVT::i32 && C->getValueType(0) == MVT::f32)
0 ; RUN: llvm-as < %s | llc
1 ; PR4057
2 define void @test_cast_float_to_char(i8* %result) nounwind {
3 entry:
4 %result_addr = alloca i8* ; [#uses=2]
5 %test = alloca float ; [#uses=2]
6 %"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
7 store i8* %result, i8** %result_addr
8 store float 0x40B2AFA160000000, float* %test, align 4
9 %0 = load float* %test, align 4 ; [#uses=1]
10 %1 = fptosi float %0 to i8 ; [#uses=1]
11 %2 = load i8** %result_addr, align 4 ; [#uses=1]
12 store i8 %1, i8* %2, align 1
13 br label %return
14
15 return: ; preds = %entry
16 ret void
17 }