xref: /llvm-project/polly/test/CodeGen/multiple_sai_fro_same_base_address.ll (revision e1f056f692d869708c1898d9d65a69ac5584a0ed)
1; RUN: opt %loadNPMPolly -polly-position=before-vectorizer '-passes=print<polly-function-scops>' -disable-output < %s 2>&1 | FileCheck %s --check-prefix=SCOP
2; RUN: opt %loadNPMPolly -polly-position=before-vectorizer -passes=polly-codegen -S < %s | FileCheck %s --check-prefix=IR
3
4; The IR has two ScopArrayInfo for the value %next.0. This used to produce two
5; phi nodes in polly.merge_new_and_old, one illegaly using the result of the
6; other. There must be only one merge phi, no need to generate them for arrays
7; of type MK_Array.
8; Derived from test-suite/MultiSource/Applications/siod/slib.c
9
10%struct.obj.2.290.322.338.354.482.546.594.626.818.898.914.962 = type { i16, i16, %union.anon.1.289.321.337.353.481.545.593.625.817.897.913.961 }
11%union.anon.1.289.321.337.353.481.545.593.625.817.897.913.961 = type { %struct.anon.0.288.320.336.352.480.544.592.624.816.896.912.960 }
12%struct.anon.0.288.320.336.352.480.544.592.624.816.896.912.960 = type { ptr, ptr }
13
14define void @leval_or() {
15entry:
16  br label %while.cond
17
18while.cond:                                       ; preds = %sw.bb1.i30, %cond.end.i28, %entry
19  %next.0 = phi ptr [ null, %entry ], [ %1, %sw.bb1.i30 ], [ null, %cond.end.i28 ]
20  br i1 undef, label %cond.end.i28, label %if.then
21
22if.then:                                          ; preds = %while.cond
23  ret void
24
25cond.end.i28:                                     ; preds = %while.cond
26  %type.i24 = getelementptr inbounds %struct.obj.2.290.322.338.354.482.546.594.626.818.898.914.962, ptr %next.0, i64 0, i32 1
27  %0 = load i16, ptr %type.i24, align 2
28  br i1 false, label %sw.bb1.i30, label %while.cond
29
30sw.bb1.i30:                                       ; preds = %cond.end.i28
31  %cdr.i29 = getelementptr inbounds %struct.obj.2.290.322.338.354.482.546.594.626.818.898.914.962, ptr %next.0, i64 0, i32 2, i32 0, i32 1
32  %1 = load ptr, ptr %cdr.i29, align 8
33  br label %while.cond
34}
35
36; SCOP:      Arrays {
37; SCOP-NEXT:     ptr MemRef_next_0;
38; SCOP-NEXT:     i16 MemRef_next_0[*];
39; SCOP-NEXT: }
40
41; IR:      polly.merge_new_and_old:
42; IR-NEXT:   %next.0.ph.merge = phi ptr [ %next.0.ph.final_reload, %polly.exiting ], [ %next.0.ph, %while.cond.region_exiting ]
43; IR-NEXT:   %indvar.next = add i64 %indvar, 1
44; IR-NEXT:   br label %while.cond
45