1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes='default<O2>' -S < %s | FileCheck %s
4 define void @copy(ptr noalias %to, ptr noalias %from) {
6 ; CHECK-NEXT: [[X:%.*]] = load i32, ptr [[FROM:%.*]], align 4
7 ; CHECK-NEXT: store i32 [[X]], ptr [[TO:%.*]], align 4
10 %x = load i32, ptr %from
15 ; Consider that %addr1 = %addr2 + 1, in which case %addr2i and %addr1i are
16 ; noalias within one iteration, but may alias across iterations.
17 define void @pr39282(ptr %addr1, ptr %addr2) {
18 ; CHECK-LABEL: @pr39282(
20 ; CHECK-NEXT: tail call void @llvm.experimental.noalias.scope.decl(metadata [[META0:![0-9]+]])
21 ; CHECK-NEXT: tail call void @llvm.experimental.noalias.scope.decl(metadata [[META3:![0-9]+]])
22 ; CHECK-NEXT: [[X_I:%.*]] = load i32, ptr [[ADDR1:%.*]], align 4, !alias.scope !3, !noalias !0
23 ; CHECK-NEXT: store i32 [[X_I]], ptr [[ADDR2:%.*]], align 4, !alias.scope !0, !noalias !3
24 ; CHECK-NEXT: [[ADDR1I_1:%.*]] = getelementptr inbounds i8, ptr [[ADDR1]], i64 4
25 ; CHECK-NEXT: [[ADDR2I_1:%.*]] = getelementptr inbounds i8, ptr [[ADDR2]], i64 4
26 ; CHECK-NEXT: tail call void @llvm.experimental.noalias.scope.decl(metadata [[META5:![0-9]+]])
27 ; CHECK-NEXT: tail call void @llvm.experimental.noalias.scope.decl(metadata [[META7:![0-9]+]])
28 ; CHECK-NEXT: [[X_I_1:%.*]] = load i32, ptr [[ADDR1I_1]], align 4, !alias.scope !7, !noalias !5
29 ; CHECK-NEXT: store i32 [[X_I_1]], ptr [[ADDR2I_1]], align 4, !alias.scope !5, !noalias !7
30 ; CHECK-NEXT: tail call void @llvm.experimental.noalias.scope.decl(metadata [[META9:![0-9]+]])
31 ; CHECK-NEXT: tail call void @llvm.experimental.noalias.scope.decl(metadata [[META11:![0-9]+]])
32 ; CHECK-NEXT: [[X_I_2:%.*]] = load i32, ptr [[ADDR1]], align 4, !alias.scope !11, !noalias !9
33 ; CHECK-NEXT: store i32 [[X_I_2]], ptr [[ADDR2]], align 4, !alias.scope !9, !noalias !11
34 ; CHECK-NEXT: tail call void @llvm.experimental.noalias.scope.decl(metadata [[META13:![0-9]+]])
35 ; CHECK-NEXT: tail call void @llvm.experimental.noalias.scope.decl(metadata [[META15:![0-9]+]])
36 ; CHECK-NEXT: [[X_I_3:%.*]] = load i32, ptr [[ADDR1I_1]], align 4, !alias.scope !15, !noalias !13
37 ; CHECK-NEXT: store i32 [[X_I_3]], ptr [[ADDR2I_1]], align 4, !alias.scope !13, !noalias !15
38 ; CHECK-NEXT: ret void
44 %i = phi i32 [ 0, %start ], [ %i.next, %body ]
46 %addr1i = getelementptr inbounds i32, ptr %addr1, i32 %j
47 %addr2i = getelementptr inbounds i32, ptr %addr2, i32 %j
48 call void @copy(ptr %addr2i, ptr %addr1i)
49 %i.next = add i32 %i, 1
50 %cmp = icmp slt i32 %i.next, 4
51 br i1 %cmp, label %body, label %end