llvm.org GIT mirror llvm / 4b3f08b
fix overflow check. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56011 91177308-0d34-0410-b5e6-96231b3b80d8 Devang Patel 11 years ago
2 changed file(s) with 49 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
15501550
15511551 // Check stride constant and the comparision constant signs to detect
15521552 // overflow.
1553 if (ICmpInst::isSignedPredicate(Predicate) &&
1554 (CmpVal & SignBit) != (CmpSSInt & SignBit))
1553 if ((CmpVal & SignBit) != (CmpSSInt & SignBit))
15551554 return Cond;
15561555
15571556 // Look for a suitable stride / iv as replacement.
0 ; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | grep phi | count 2
1 ; PR 2779
2 @g_19 = common global i32 0 ; [#uses=3]
3 @"\01LC" = internal constant [4 x i8] c"%d\0A\00" ; <[4 x i8]*> [#uses=1]
4
5 define i32 @func_8(i8 zeroext %p_9) nounwind {
6 entry:
7 ret i32 1
8 }
9
10 define i32 @func_3(i8 signext %p_5) nounwind {
11 entry:
12 ret i32 1
13 }
14
15 define void @func_1() nounwind {
16 entry:
17 br label %bb
18
19 bb: ; preds = %bb, %entry
20 %indvar = phi i16 [ 0, %entry ], [ %indvar.next, %bb ] ; [#uses=2]
21 %tmp = sub i16 0, %indvar ; [#uses=1]
22 %tmp27 = trunc i16 %tmp to i8 ; [#uses=1]
23 load i32* @g_19, align 4 ; :0 [#uses=2]
24 add i32 %0, 1 ; :1 [#uses=1]
25 store i32 %1, i32* @g_19, align 4
26 trunc i32 %0 to i8 ; :2 [#uses=1]
27 tail call i32 @func_8( i8 zeroext %2 ) nounwind ; :3 [#uses=0]
28 shl i8 %tmp27, 2 ; :4 [#uses=1]
29 add i8 %4, -112 ; :5 [#uses=1]
30 tail call i32 @func_3( i8 signext %5 ) nounwind ; :6 [#uses=0]
31 %indvar.next = add i16 %indvar, 1 ; [#uses=2]
32 %exitcond = icmp eq i16 %indvar.next, -28 ; [#uses=1]
33 br i1 %exitcond, label %return, label %bb
34
35 return: ; preds = %bb
36 ret void
37 }
38
39 define i32 @main() nounwind {
40 entry:
41 tail call void @func_1( ) nounwind
42 load i32* @g_19, align 4 ; :0 [#uses=1]
43 tail call i32 (i8*, ...)* @printf( i8* getelementptr ([4 x i8]* @"\01LC", i32 0, i32 0), i32 %0 ) nounwind ; :1 [#uses=0]
44 ret i32 0
45 }
46
47 declare i32 @printf(i8*, ...) nounwind