1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
3 target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
5 ; A multi-dimensional array in a nested loop doing vector stores that
6 ; aren't yet aligned. Instcombine can understand the addressing in the
7 ; Nice case to prove 16 byte alignment. In the Awkward case, the inner
8 ; array dimension is not even, so the stores to it won't always be
9 ; aligned. Instcombine should prove alignment in exactly one of the two
12 @Nice = global [1001 x [20000 x double]] zeroinitializer, align 32
13 @Awkward = global [1001 x [20001 x double]] zeroinitializer, align 32
15 define void @foo() nounwind {
18 ; CHECK-NEXT: br label [[BB7_OUTER:%.*]]
20 ; CHECK-NEXT: [[I:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVAR_NEXT26:%.*]], [[BB11:%.*]] ]
21 ; CHECK-NEXT: br label [[BB1:%.*]]
23 ; CHECK-NEXT: [[J:%.*]] = phi i64 [ 0, [[BB7_OUTER]] ], [ [[INDVAR_NEXT:%.*]], [[BB1]] ]
24 ; CHECK-NEXT: [[T4:%.*]] = getelementptr [1001 x [20000 x double]], [1001 x [20000 x double]]* @Nice, i64 0, i64 [[I]], i64 [[J]]
25 ; CHECK-NEXT: [[Q:%.*]] = bitcast double* [[T4]] to <2 x double>*
26 ; CHECK-NEXT: store <2 x double> zeroinitializer, <2 x double>* [[Q]], align 16
27 ; CHECK-NEXT: [[S4:%.*]] = getelementptr [1001 x [20001 x double]], [1001 x [20001 x double]]* @Awkward, i64 0, i64 [[I]], i64 [[J]]
28 ; CHECK-NEXT: [[R:%.*]] = bitcast double* [[S4]] to <2 x double>*
29 ; CHECK-NEXT: store <2 x double> zeroinitializer, <2 x double>* [[R]], align 8
30 ; CHECK-NEXT: [[INDVAR_NEXT]] = add i64 [[J]], 2
31 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVAR_NEXT]], 556
32 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[BB11]], label [[BB1]]
34 ; CHECK-NEXT: [[INDVAR_NEXT26]] = add i64 [[I]], 1
35 ; CHECK-NEXT: [[EXITCOND27:%.*]] = icmp eq i64 [[INDVAR_NEXT26]], 991
36 ; CHECK-NEXT: br i1 [[EXITCOND27]], label [[RETURN_SPLIT:%.*]], label [[BB7_OUTER]]
37 ; CHECK: return.split:
38 ; CHECK-NEXT: ret void
44 %i = phi i64 [ 0, %entry ], [ %indvar.next26, %bb11 ]
48 %j = phi i64 [ 0, %bb7.outer ], [ %indvar.next, %bb1 ]
50 %t4 = getelementptr [1001 x [20000 x double]], [1001 x [20000 x double]]* @Nice, i64 0, i64 %i, i64 %j
51 %q = bitcast double* %t4 to <2 x double>*
52 store <2 x double><double 0.0, double 0.0>, <2 x double>* %q, align 8
54 %s4 = getelementptr [1001 x [20001 x double]], [1001 x [20001 x double]]* @Awkward, i64 0, i64 %i, i64 %j
55 %r = bitcast double* %s4 to <2 x double>*
56 store <2 x double><double 0.0, double 0.0>, <2 x double>* %r, align 8
58 %indvar.next = add i64 %j, 2
59 %exitcond = icmp eq i64 %indvar.next, 556
60 br i1 %exitcond, label %bb11, label %bb1
63 %indvar.next26 = add i64 %i, 1
64 %exitcond27 = icmp eq i64 %indvar.next26, 991
65 br i1 %exitcond27, label %return.split, label %bb7.outer