1f31811f2SFangrui Song; RUN: opt -basic-aa -loop-versioning -S < %s | FileCheck %s
27c19c89dSArthur Eubanks; RUN: opt -aa-pipeline=basic-aa -passes=loop-versioning -S < %s | FileCheck %s
3cee313d2SEric Christopher
4cee313d2SEric Christophertarget datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
5cee313d2SEric Christopher
6cee313d2SEric Christopher; Version this loop with overlap checks between a, c and b, c.
7cee313d2SEric Christopher
8cee313d2SEric Christopherdefine void @f(i32* %a, i32* %b, i32* %c) {
9cee313d2SEric Christopherentry:
10cee313d2SEric Christopher  br label %for.body
11cee313d2SEric Christopher
12cee313d2SEric Christopher; CHECK: for.body.lver.check:
13cee313d2SEric Christopher; CHECK:   icmp
14cee313d2SEric Christopher; CHECK:   icmp
15cee313d2SEric Christopher; CHECK:   icmp
16cee313d2SEric Christopher; CHECK:   icmp
17cee313d2SEric Christopher; CHECK-NOT: icmp
18*e844f053SFlorian Hahn; CHECK:   br i1 %conflict.rdx, label %for.body.ph.lver.orig, label %for.body.ph
19cee313d2SEric Christopher
20cee313d2SEric Christopher; CHECK: for.body.ph.lver.orig:
21cee313d2SEric Christopher; CHECK: for.body.lver.orig:
22060a4fccSTaWeiTu; CHECK:   br i1 %exitcond.lver.orig, label %for.end.loopexit, label %for.body.lver.orig
23cee313d2SEric Christopher; CHECK: for.body.ph:
24cee313d2SEric Christopher; CHECK: for.body:
25060a4fccSTaWeiTu; CHECK:   br i1 %exitcond, label %for.end.loopexit12, label %for.body
26060a4fccSTaWeiTu; CHECK: for.end.loopexit:
27060a4fccSTaWeiTu; CHECK:   br label %for.end
28060a4fccSTaWeiTu; CHECK: for.end.loopexit12:
29060a4fccSTaWeiTu; CHECK:   br label %for.end
30cee313d2SEric Christopher; CHECK: for.end:
31cee313d2SEric Christopher
32cee313d2SEric Christopherfor.body:                                         ; preds = %for.body, %entry
33cee313d2SEric Christopher  %ind = phi i64 [ 0, %entry ], [ %add, %for.body ]
34cee313d2SEric Christopher
35cee313d2SEric Christopher  %arrayidxA = getelementptr inbounds i32, i32* %a, i64 %ind
36cee313d2SEric Christopher  %loadA = load i32, i32* %arrayidxA, align 4
37cee313d2SEric Christopher
38cee313d2SEric Christopher  %arrayidxB = getelementptr inbounds i32, i32* %b, i64 %ind
39cee313d2SEric Christopher  %loadB = load i32, i32* %arrayidxB, align 4
40cee313d2SEric Christopher
41cee313d2SEric Christopher  %mulC = mul i32 %loadA, %loadB
42cee313d2SEric Christopher
43cee313d2SEric Christopher  %arrayidxC = getelementptr inbounds i32, i32* %c, i64 %ind
44cee313d2SEric Christopher  store i32 %mulC, i32* %arrayidxC, align 4
45cee313d2SEric Christopher
46cee313d2SEric Christopher  %add = add nuw nsw i64 %ind, 1
47cee313d2SEric Christopher  %exitcond = icmp eq i64 %add, 20
48cee313d2SEric Christopher  br i1 %exitcond, label %for.end, label %for.body
49cee313d2SEric Christopher
50cee313d2SEric Christopherfor.end:                                          ; preds = %for.body
51cee313d2SEric Christopher  ret void
52cee313d2SEric Christopher}
53