1 ; RUN: opt < %s -basicaa -dse -S | FileCheck %s
2 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4 @A = common global [100 x i32] zeroinitializer, align 16
5 @x = common global i32 0
10 ; for(int i=0;i<N;++i)
14 ;; Stores should not be optimized away.
16 define void @test_01(i32 %N) #0 {
20 %2 = load i32, i32* %1
21 store i32 %2, i32* getelementptr inbounds ([100 x i32], [100 x i32]* @A, i32 0, i64 0)
25 ; <label>:3 ; preds = %14, %0
26 %4 = load i32, i32* %i
27 %5 = load i32, i32* %1
28 %6 = icmp slt i32 %4, %5
29 br i1 %6, label %7, label %17
31 ; <label>:7 ; preds = %3
32 %8 = load i32, i32* %i
33 %9 = load i32, i32* %i
34 %10 = sext i32 %9 to i64
35 %11 = getelementptr inbounds [100 x i32], [100 x i32]* @A, i32 0, i64 %10
36 %12 = load i32, i32* %11
37 %13 = add nsw i32 %12, %8
38 store i32 %13, i32* %11
41 ; <label>:14 ; preds = %7
42 %15 = load i32, i32* %i
43 %16 = add nsw i32 %15, 1
44 store i32 %16, i32* %i
47 ; <label>:17 ; preds = %3
48 store i32 10, i32* getelementptr inbounds ([100 x i32], [100 x i32]* @A, i32 0, i64 0)
51 ; CHECK-LABEL: @test_01(
52 ; CHECK: store i32 %2, i32* getelementptr inbounds ([100 x i32], [100 x i32]* @A, i32 0, i64 0)
53 ; CHECK: store i32 %13, i32* %11
54 ; CHECK: store i32 10, i32* getelementptr inbounds ([100 x i32], [100 x i32]* @A, i32 0, i64 0)
60 ; for(int i=0;i<N;++i)
64 ;; Stores should not be optimized away.
65 define void @test_02(i32 %N) #0 {
69 %2 = load i32, i32* %1
70 store i32 %2, i32* getelementptr inbounds ([100 x i32], [100 x i32]* @A, i32 0, i64 0)
74 ; <label>:3 ; preds = %12, %0
75 %4 = load i32, i32* %i
76 %5 = load i32, i32* %1
77 %6 = icmp slt i32 %4, %5
78 br i1 %6, label %7, label %15
80 ; <label>:7 ; preds = %3
81 %8 = load i32, i32* %i
82 %9 = load i32, i32* %i
83 %10 = sext i32 %9 to i64
84 %11 = getelementptr inbounds [100 x i32], [100 x i32]* @A, i32 0, i64 %10
85 store i32 %8, i32* %11
88 ; <label>:12 ; preds = %7
89 %13 = load i32, i32* %i
90 %14 = add nsw i32 %13, 1
91 store i32 %14, i32* %i
94 ; <label>:15 ; preds = %3
95 store i32 10, i32* getelementptr inbounds ([100 x i32], [100 x i32]* @A, i32 0, i64 0)
99 ; CHECK-LABEL: @test_02(
100 ; CHECK-NOT: store i32 %2, i32* getelementptr inbounds ([100 x i32], [100 x i32]* @A, i32 0, i64 0)
101 ; CHECK: store i32 %7, i32* %10
102 ; CHECK: store i32 10, i32* getelementptr inbounds ([100 x i32], [100 x i32]* @A, i32 0, i64 0)