llvm.org GIT mirror llvm / 19378d6
When attempting to sign-extend an addrec by interpreting the step value as unsigned, the start value and the addrec itself still need to be treated as signed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77078 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 11 years ago
2 changed file(s) with 76 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
922922 getTruncateOrZeroExtend(Step, Start->getType()));
923923 Add = getAddExpr(Start, UMul);
924924 OperandExtendedAdd =
925 getAddExpr(getZeroExtendExpr(Start, WideTy),
925 getAddExpr(getSignExtendExpr(Start, WideTy),
926926 getMulExpr(getZeroExtendExpr(CastedMaxBECount, WideTy),
927927 getZeroExtendExpr(Step, WideTy)));
928 if (getZeroExtendExpr(Add, WideTy) == OperandExtendedAdd)
928 if (getSignExtendExpr(Add, WideTy) == OperandExtendedAdd)
929929 // Return the expression with the addrec on the outside.
930930 return getAddRecExpr(getSignExtendExpr(Start, Ty),
931931 getZeroExtendExpr(Step, Ty),
0 ; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output | FileCheck %s
1
2 ; CHECK: %tmp3 = sext i8 %tmp2 to i32
3 ; CHECK: --> (sext i8 {0,+,1} to i32) Exits: -1
4 ; CHECK: %tmp4 = mul i32 %tmp3, %i.02
5 ; CHECK: --> ((sext i8 {0,+,1} to i32) * {0,+,1}) Exits: {0,+,-1}
6
7 ; These sexts are not foldable.
8
9 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64"
10
11 @table = common global [32 x [256 x i32]] zeroinitializer, align 32 ; <[32 x [256 x i32]]*> [#uses=2]
12
13 define i32 @main() nounwind {
14 entry:
15 br i1 false, label %bb5, label %bb.nph3
16
17 bb.nph3: ; preds = %entry
18 br label %bb
19
20 bb: ; preds = %bb4, %bb.nph3
21 %i.02 = phi i32 [ %tmp10, %bb4 ], [ 0, %bb.nph3 ] ; [#uses=3]
22 br i1 false, label %bb3, label %bb.nph
23
24 bb.nph: ; preds = %bb
25 br label %bb1
26
27 bb1: ; preds = %bb2, %bb.nph
28 %j.01 = phi i32 [ %tmp8, %bb2 ], [ 0, %bb.nph ] ; [#uses=3]
29 %tmp2 = trunc i32 %j.01 to i8 ; [#uses=1]
30 %tmp3 = sext i8 %tmp2 to i32 ; [#uses=1]
31 %tmp4 = mul i32 %tmp3, %i.02 ; [#uses=1]
32 %tmp5 = sext i32 %i.02 to i64 ; [#uses=1]
33 %tmp6 = sext i32 %j.01 to i64 ; [#uses=1]
34 %tmp7 = getelementptr [32 x [256 x i32]]* @table, i64 0, i64 %tmp5, i64 %tmp6 ; [#uses=1]
35 store i32 %tmp4, i32* %tmp7, align 4
36 %tmp8 = add i32 %j.01, 1 ; [#uses=2]
37 br label %bb2
38
39 bb2: ; preds = %bb1
40 %phitmp1 = icmp sgt i32 %tmp8, 255 ; [#uses=1]
41 br i1 %phitmp1, label %bb2.bb3_crit_edge, label %bb1
42
43 bb2.bb3_crit_edge: ; preds = %bb2
44 br label %bb3
45
46 bb3: ; preds = %bb2.bb3_crit_edge, %bb
47 %tmp10 = add i32 %i.02, 1 ; [#uses=2]
48 br label %bb4
49
50 bb4: ; preds = %bb3
51 %phitmp = icmp sgt i32 %tmp10, 31 ; [#uses=1]
52 br i1 %phitmp, label %bb4.bb5_crit_edge, label %bb
53
54 bb4.bb5_crit_edge: ; preds = %bb4
55 br label %bb5
56
57 bb5: ; preds = %bb4.bb5_crit_edge, %entry
58 %tmp12 = load i32* getelementptr ([32 x [256 x i32]]* @table, i64 0, i64 9, i64 132), align 16 ; [#uses=1]
59 %tmp13 = icmp eq i32 %tmp12, -1116 ; [#uses=1]
60 br i1 %tmp13, label %bb7, label %bb6
61
62 bb6: ; preds = %bb5
63 call void @abort() noreturn nounwind
64 unreachable
65
66 bb7: ; preds = %bb5
67 br label %return
68
69 return: ; preds = %bb7
70 ret i32 0
71 }
72
73 declare void @abort() noreturn nounwind