• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -S -gvn < %s | FileCheck %s
3
4target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5target triple = "x86_64-unknown-linux-gnu"
6
7; The load in the loop can not bypass the data from the previous loop. The store above it in the loop aliases.
8define void @foo() {
9; CHECK-LABEL: @foo(
10; CHECK-NEXT:  entry:
11; CHECK-NEXT:    [[A:%.*]] = alloca [3 x i32], align 4
12; CHECK-NEXT:    br label [[FOR_BODY:%.*]]
13; CHECK:       for.cond.cleanup:
14; CHECK-NEXT:    ret void
15; CHECK:       for.body:
16; CHECK-NEXT:    [[INDVARS_IV:%.*]] = phi i64 [ 1, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
17; CHECK-NEXT:    [[P_017:%.*]] = phi i32* [ undef, [[ENTRY]] ], [ [[ARRAYIDX3:%.*]], [[FOR_BODY]] ]
18; CHECK-NEXT:    [[TMP0:%.*]] = add nsw i64 [[INDVARS_IV]], -1
19; CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds [3 x i32], [3 x i32]* [[A]], i64 0, i64 [[TMP0]]
20; CHECK-NEXT:    store i32 50, i32* [[ARRAYIDX]], align 4
21; CHECK-NEXT:    [[TMP1:%.*]] = shl i64 [[INDVARS_IV]], 1
22; CHECK-NEXT:    [[TMP2:%.*]] = load i32, i32* [[P_017]], align 4
23; CHECK-NEXT:    [[TMP3:%.*]] = trunc i64 [[TMP1]] to i32
24; CHECK-NEXT:    [[ADD1:%.*]] = add nsw i32 [[TMP2]], [[TMP3]]
25; CHECK-NEXT:    [[ARRAYIDX3]] = getelementptr inbounds [3 x i32], [3 x i32]* [[A]], i64 0, i64 [[INDVARS_IV]]
26; CHECK-NEXT:    store i32 60, i32* [[ARRAYIDX3]], align 4
27; CHECK-NEXT:    [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
28; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT]], 3
29; CHECK-NEXT:    br i1 [[EXITCOND]], label [[FOR_BODY]], label [[FOR_COND_CLEANUP:%.*]]
30;
31entry:
32  %a = alloca [3 x i32], align 4
33  br label %for.body
34
35for.cond.cleanup:                                 ; preds = %for.body
36  ret void
37
38for.body:                                         ; preds = %for.body, %entry
39  %indvars.iv = phi i64 [ 1, %entry ], [ %indvars.iv.next, %for.body ]
40  %p.017 = phi i32* [ undef, %entry ], [ %arrayidx3, %for.body ]
41  %0 = add nsw i64 %indvars.iv, -1
42  %arrayidx = getelementptr inbounds [3 x i32], [3 x i32]* %a, i64 0, i64 %0
43  store i32 50, i32* %arrayidx, align 4
44  %1 = shl i64 %indvars.iv, 1
45  %2 = load i32, i32* %p.017, align 4
46  %3 = trunc i64 %1 to i32
47  %add1 = add nsw i32 %2, %3
48  %arrayidx3 = getelementptr inbounds [3 x i32], [3 x i32]* %a, i64 0, i64 %indvars.iv
49  store i32 60, i32* %arrayidx3, align 4
50  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
51  %exitcond = icmp ne i64 %indvars.iv.next, 3
52  br i1 %exitcond, label %for.body, label %for.cond.cleanup
53}
54