llvm.org GIT mirror llvm / 5813ee1
[ConstantFold] Don't try to strip fp -> int bitcasts to simplify icmps ConstantFold has logic to take icmp (bitcast x to y), null and strip the bitcast. This makes sense in general, but not if x has floating-point type. In this case, we'd need a fcmp, not an icmp, and the code will assert. We normally don't see this situation because we constant fold fp -> int bitcasts, however, we'll see it for bitcasts of ppc_fp128 -> i128. This is because that bitcast is Endian-dependent, and as a result, we don't simplify it in ConstantFold (we could, but no one has yet added the necessary logic). Regardless, ConstantFold should not depend on that canonicalization for correctness. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268534 91177308-0d34-0410-b5e6-96231b3b80d8 Hal Finkel 3 years ago
2 changed file(s) with 56 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
15281528 case Instruction::BitCast:
15291529 case Instruction::ZExt:
15301530 case Instruction::SExt:
1531 // We can't evaluate floating point casts or truncations.
1532 if (CE1Op0->getType()->isFloatingPointTy())
1533 break;
1534
15311535 // If the cast is not actually changing bits, and the second operand is a
15321536 // null pointer, do the comparison with the pre-casted value.
15331537 if (V2->isNullValue() &&
0 ; RUN: opt -S -ipsccp < %s | FileCheck %s
1 target datalayout = "E-m:e-i64:64-n32:64"
2 target triple = "powerpc64-bgq-linux"
3
4 define void @test(i32 signext %n) {
5
6 ; CHECK-LABEL: @test
7
8 entry:
9 br i1 undef, label %if.then, label %if.end
10
11 if.then: ; preds = %entry
12 ret void
13
14 if.end: ; preds = %entry
15 br i1 undef, label %if.then2, label %if.end4
16
17 if.then2: ; preds = %if.end
18 unreachable
19
20 if.end4: ; preds = %if.end
21 %sub.n = select i1 undef, i32 undef, i32 %n
22 switch i32 %sub.n, label %if.else14 [
23 i32 0, label %if.then9
24 i32 1, label %if.then12
25 ]
26
27 if.then9: ; preds = %if.end4
28 unreachable
29
30 if.then12: ; preds = %if.end4
31 unreachable
32
33 if.else14: ; preds = %if.end4
34 br label %do.body
35
36 do.body: ; preds = %do.body, %if.else14
37 %scale.0 = phi ppc_fp128 [ 0xM3FF00000000000000000000000000000, %if.else14 ], [ %scale.0, %do.body ]
38 br i1 undef, label %do.body, label %if.then33
39
40 if.then33: ; preds = %do.body
41 br i1 undef, label %_ZN5boost4math4signIgEEiRKT_.exit30, label %cond.false.i28
42
43 cond.false.i28: ; preds = %if.then33
44 %0 = bitcast ppc_fp128 %scale.0 to i128
45 %tobool.i26 = icmp slt i128 %0, 0
46 br label %_ZN5boost4math4signIgEEiRKT_.exit30
47
48 _ZN5boost4math4signIgEEiRKT_.exit30: ; preds = %cond.false.i28, %if.then33
49 unreachable
50 }
51