1; RUN: opt %loadPolly -polly-import-jscop -polly-import-jscop-postfix=transformed -polly-opt-isl -debug-only=polly-opt-isl -disable-output < %s 2>&1 | FileCheck %s
2; REQUIRES: asserts
3;
4; void pattern_matching_based_opts_splitmap(double C[static const restrict 2][2], double A[static const restrict 2][784], double B[static const restrict 784][2]) {
5;  for (int i = 0; i < 2; i+=1)
6;    for (int j = 0; j < 2; j+=1)
7;      for (int k = 0; k < 784; k+=1)
8;        C[i][j] += A[i][k] * B[k][j];
9;}
10;
11; Check that the pattern matching detects the matrix multiplication pattern
12; when the AccMap cannot be reduced to a single disjunct.
13;
14; CHECK: The matrix multiplication pattern was detected
15;
16; ModuleID = 'pattern_matching_based_opts_splitmap.ll'
17;
18; Function Attrs: noinline nounwind uwtable
19define void @pattern_matching_based_opts_splitmap([2 x double]* noalias dereferenceable(32) %C, [784 x double]* noalias dereferenceable(12544) %A, [2 x double]* noalias dereferenceable(12544) %B) {
20entry:
21  br label %for.body
22
23for.body:                                         ; preds = %entry, %for.inc21
24  %i = phi i64 [ 0, %entry ], [ %add22, %for.inc21 ]
25  br label %for.body3
26
27for.body3:                                        ; preds = %for.body, %for.inc18
28  %j = phi i64 [ 0, %for.body ], [ %add19, %for.inc18 ]
29  br label %for.body6
30
31for.body6:                                        ; preds = %for.body3, %for.body6
32  %k = phi i64 [ 0, %for.body3 ], [ %add17, %for.body6 ]
33  %arrayidx8 = getelementptr inbounds [784 x double], [784 x double]* %A, i64 %i, i64 %k
34  %tmp6 = load double, double* %arrayidx8, align 8
35  %arrayidx12 = getelementptr inbounds [2 x double], [2 x double]* %B, i64 %k, i64 %j
36  %tmp10 = load double, double* %arrayidx12, align 8
37  %mul = fmul double %tmp6, %tmp10
38  %arrayidx16 = getelementptr inbounds [2 x double], [2 x double]* %C, i64 %i, i64 %j
39  %tmp14 = load double, double* %arrayidx16, align 8
40  %add = fadd double %tmp14, %mul
41  store double %add, double* %arrayidx16, align 8
42  %add17 = add nsw i64 %k, 1
43  %cmp5 = icmp slt i64 %add17, 784
44  br i1 %cmp5, label %for.body6, label %for.inc18
45
46for.inc18:                                        ; preds = %for.body6
47  %add19 = add nsw i64 %j, 1
48  %cmp2 = icmp slt i64 %add19, 2
49  br i1 %cmp2, label %for.body3, label %for.inc21
50
51for.inc21:                                        ; preds = %for.inc18
52  %add22 = add nsw i64 %i, 1
53  %cmp = icmp slt i64 %add22, 2
54  br i1 %cmp, label %for.body, label %for.end23
55
56for.end23:                                        ; preds = %for.inc21
57  ret void
58}
59
60