xref: /llvm-project/llvm/test/Transforms/PhaseOrdering/X86/loop-vectorizer-noalias.ll (revision 29441e4f5fa5f5c7709f7cf180815ba97f611297)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2; RUN: opt -S -O3 -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
3
4define internal void @acc(ptr noalias noundef %val, ptr noalias noundef %prev) {
5entry:
6  %0 = load i8, ptr %prev, align 1
7  %conv = zext i8 %0 to i32
8  %1 = load i8, ptr %val, align 1
9  %conv1 = zext i8 %1 to i32
10  %add = add nsw i32 %conv1, %conv
11  %conv2 = trunc i32 %add to i8
12  store i8 %conv2, ptr %val, align 1
13  ret void
14}
15
16; This loop should not get vectorized.
17define void @accsum(ptr noundef %vals, i64 noundef %num) #0 {
18; CHECK-LABEL: define void @accsum(
19; CHECK-SAME: ptr noundef captures(none) [[VALS:%.*]], i64 noundef [[NUM:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
20; CHECK-NEXT:  entry:
21; CHECK-NEXT:    [[CMP1:%.*]] = icmp ugt i64 [[NUM]], 1
22; CHECK-NEXT:    br i1 [[CMP1]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_END:%.*]]
23; CHECK:       for.body.preheader:
24; CHECK-NEXT:    [[LOAD_INITIAL:%.*]] = load i8, ptr [[VALS]], align 1
25; CHECK-NEXT:    br label [[FOR_BODY:%.*]]
26; CHECK:       for.body:
27; CHECK-NEXT:    [[STORE_FORWARDED:%.*]] = phi i8 [ [[LOAD_INITIAL]], [[FOR_BODY_PREHEADER]] ], [ [[ADD_I:%.*]], [[FOR_BODY]] ]
28; CHECK-NEXT:    [[I_02:%.*]] = phi i64 [ 1, [[FOR_BODY_PREHEADER]] ], [ [[INC:%.*]], [[FOR_BODY]] ]
29; CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds i8, ptr [[VALS]], i64 [[I_02]]
30; CHECK-NEXT:    [[TMP0:%.*]] = load i8, ptr [[ARRAYIDX]], align 1, !alias.scope [[META0:![0-9]+]], !noalias [[META3:![0-9]+]]
31; CHECK-NEXT:    [[ADD_I]] = add i8 [[TMP0]], [[STORE_FORWARDED]]
32; CHECK-NEXT:    store i8 [[ADD_I]], ptr [[ARRAYIDX]], align 1, !alias.scope [[META0]], !noalias [[META3]]
33; CHECK-NEXT:    [[INC]] = add nuw i64 [[I_02]], 1
34; CHECK-NEXT:    [[EXITCOND_NOT:%.*]] = icmp eq i64 [[INC]], [[NUM]]
35; CHECK-NEXT:    br i1 [[EXITCOND_NOT]], label [[FOR_END]], label [[FOR_BODY]]
36; CHECK:       for.end:
37; CHECK-NEXT:    ret void
38;
39entry:
40  br label %for.cond
41
42for.cond:                                         ; preds = %for.inc, %entry
43  %i.0 = phi i64 [ 1, %entry ], [ %inc, %for.inc ]
44  %cmp = icmp ult i64 %i.0, %num
45  br i1 %cmp, label %for.body, label %for.cond.cleanup
46
47for.cond.cleanup:                                 ; preds = %for.cond
48  br label %for.end
49
50for.body:                                         ; preds = %for.cond
51  %arrayidx = getelementptr inbounds i8, ptr %vals, i64 %i.0
52  %sub = sub i64 %i.0, 1
53  %arrayidx1 = getelementptr inbounds i8, ptr %vals, i64 %sub
54  call void @acc(ptr noundef %arrayidx, ptr noundef %arrayidx1)
55  br label %for.inc
56
57for.inc:                                          ; preds = %for.body
58  %inc = add i64 %i.0, 1
59  br label %for.cond
60
61for.end:                                          ; preds = %for.cond.cleanup
62  ret void
63}
64
65; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
66declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
67
68; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
69declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
70
71attributes #0 = { "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87"}
72;.
73; CHECK: [[META0]] = !{[[META1:![0-9]+]]}
74; CHECK: [[META1]] = distinct !{[[META1]], [[META2:![0-9]+]], !"acc: %val"}
75; CHECK: [[META2]] = distinct !{[[META2]], !"acc"}
76; CHECK: [[META3]] = !{[[META4:![0-9]+]]}
77; CHECK: [[META4]] = distinct !{[[META4]], [[META2]], !"acc: %prev"}
78;.
79