1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt < %s -passes=infer-alignment -S | FileCheck %s
4 ; A multi-dimensional array in a nested loop.inner doing vector stores that
5 ; aren't yet aligned. InferAlignment can understand the addressing in the
6 ; Nice case to prove 16 byte alignment. In the Awkward case, the inner
7 ; array dimension is not even, so the stores to it won't always be aligned.
9 ; InferAlignment should prove alignment in exactly one of the two cases.
11 @Nice = global [1001 x [20000 x double]] zeroinitializer, align 32
12 @Awkward = global [1001 x [20001 x double]] zeroinitializer, align 32
14 define void @nested_loop() {
15 ; CHECK-LABEL: define void @nested_loop() {
17 ; CHECK-NEXT: br label [[LOOP_OUTER:%.*]]
19 ; CHECK-NEXT: [[I:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[I_NEXT:%.*]], [[LOOP_OUTER_TAIL:%.*]] ]
20 ; CHECK-NEXT: br label [[LOOP_INNER:%.*]]
22 ; CHECK-NEXT: [[J:%.*]] = phi i64 [ 0, [[LOOP_OUTER]] ], [ [[J_NEXT:%.*]], [[LOOP_INNER_TAIL:%.*]] ]
23 ; CHECK-NEXT: [[GEP_1:%.*]] = getelementptr [1001 x [20000 x double]], ptr @Nice, i64 0, i64 [[I]], i64 [[J]]
24 ; CHECK-NEXT: store <2 x double> zeroinitializer, ptr [[GEP_1]], align 16
25 ; CHECK-NEXT: [[LOAD_1:%.*]] = load <2 x double>, ptr [[GEP_1]], align 16
26 ; CHECK-NEXT: [[GEP_2:%.*]] = getelementptr [1001 x [20001 x double]], ptr @Awkward, i64 0, i64 [[I]], i64 [[J]]
27 ; CHECK-NEXT: store <2 x double> zeroinitializer, ptr [[GEP_2]], align 8
28 ; CHECK-NEXT: [[LOAD_2:%.*]] = load <2 x double>, ptr [[GEP_2]], align 8
29 ; CHECK-NEXT: br label [[LOOP_INNER_TAIL]]
30 ; CHECK: loop.inner.tail:
31 ; CHECK-NEXT: [[J_NEXT]] = add i64 [[J]], 2
32 ; CHECK-NEXT: [[J_CMP:%.*]] = icmp eq i64 [[J_NEXT]], 556
33 ; CHECK-NEXT: br i1 [[J_CMP]], label [[LOOP_OUTER_TAIL]], label [[LOOP_INNER]]
34 ; CHECK: loop.outer.tail:
35 ; CHECK-NEXT: [[I_NEXT]] = add i64 [[I]], 1
36 ; CHECK-NEXT: [[I_CMP:%.*]] = icmp eq i64 [[I_NEXT]], 991
37 ; CHECK-NEXT: br i1 [[I_CMP]], label [[RETURN:%.*]], label [[LOOP_OUTER]]
39 ; CHECK-NEXT: ret void
45 %i = phi i64 [ 0, %entry ], [ %i.next, %loop.outer.tail ]
49 %j = phi i64 [ 0, %loop.outer ], [ %j.next, %loop.inner.tail ]
51 %gep.1 = getelementptr [1001 x [20000 x double]], ptr @Nice, i64 0, i64 %i, i64 %j
52 store <2 x double><double 0.0, double 0.0>, ptr %gep.1, align 8
53 %load.1 = load <2 x double>, ptr %gep.1, align 8
55 %gep.2 = getelementptr [1001 x [20001 x double]], ptr @Awkward, i64 0, i64 %i, i64 %j
56 store <2 x double><double 0.0, double 0.0>, ptr %gep.2, align 8
57 %load.2 = load <2 x double>, ptr %gep.2, align 8
59 br label %loop.inner.tail
62 %j.next = add i64 %j, 2
63 %j.cmp = icmp eq i64 %j.next, 556
64 br i1 %j.cmp, label %loop.outer.tail, label %loop.inner
67 %i.next = add i64 %i, 1
68 %i.cmp = icmp eq i64 %i.next, 991
69 br i1 %i.cmp, label %return, label %loop.outer