1 ; RUN: opt -passes=loop-versioning -S < %s | FileCheck %s
3 ; Make sure all PHIs are properly updated in the exit block. Based on
6 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
7 target triple = "x86_64-unknown-linux-gnu"
9 @x = external global [2 x [3 x [5 x i16]]]
11 ; CHECK-LABEL: @phi_with_undef
12 define void @phi_with_undef() {
13 bb6.lr.ph: ; preds = %bb5.preheader
16 bb6: ; preds = %bb6.lr.ph, %bb6
17 %_tmp1423 = phi i64 [ undef, %bb6.lr.ph ], [ %_tmp142, %bb6 ]
18 %_tmp123 = getelementptr [2 x [3 x [5 x i16]]], ptr @x, i16 0, i64 undef
19 %_tmp126 = getelementptr [3 x [5 x i16]], ptr %_tmp123, i16 0, i64 %_tmp1423
20 %_tmp129 = getelementptr [5 x i16], ptr %_tmp126, i16 0, i64 undef
21 %_tmp130 = load i16, ptr %_tmp129
22 store i16 undef, ptr getelementptr ([2 x [3 x [5 x i16]]], ptr @x, i64 0, i64 undef, i64 undef, i64 undef)
23 %_tmp142 = add i64 %_tmp1423, 1
24 br i1 false, label %bb6, label %loop.exit
26 loop.exit: ; preds = %bb6
27 %_tmp142.lcssa = phi i64 [ %_tmp142, %bb6 ]
28 %split = phi i16 [ undef, %bb6 ]
29 ; CHECK: %split.ph = phi i16 [ undef, %bb6.lver.orig ]
30 ; CHECK: %split.ph3 = phi i16 [ undef, %bb6 ]
31 ; CHECK: %split = phi i16 [ %split.ph, %loop.exit.loopexit ], [ %split.ph3, %loop.exit.loopexit1 ]
34 bb9: ; preds = %bb9.loopexit, %bb1
38 ; CHECK-LABEL: @phi_with_non_loop_defined_value
39 define void @phi_with_non_loop_defined_value() {
40 bb6.lr.ph: ; preds = %bb5.preheader
44 bb6: ; preds = %bb6.lr.ph, %bb6
45 %_tmp1423 = phi i64 [ undef, %bb6.lr.ph ], [ %_tmp142, %bb6 ]
46 %_tmp123 = getelementptr [2 x [3 x [5 x i16]]], ptr @x, i16 0, i64 undef
47 %_tmp126 = getelementptr [3 x [5 x i16]], ptr %_tmp123, i16 0, i64 %_tmp1423
48 %_tmp129 = getelementptr [5 x i16], ptr %_tmp126, i16 0, i64 undef
49 %_tmp130 = load i16, ptr %_tmp129
50 store i16 undef, ptr getelementptr ([2 x [3 x [5 x i16]]], ptr @x, i64 0, i64 undef, i64 undef, i64 undef)
51 %_tmp142 = add i64 %_tmp1423, 1
52 br i1 false, label %bb6, label %loop.exit
54 loop.exit: ; preds = %bb6
55 %_tmp142.lcssa = phi i64 [ %_tmp142, %bb6 ]
56 %split = phi i16 [ %t, %bb6 ]
57 ; CHECK: %split.ph = phi i16 [ %t, %bb6.lver.orig ]
58 ; CHECK: %split.ph3 = phi i16 [ %t, %bb6 ]
59 ; CHECK: %split = phi i16 [ %split.ph, %loop.exit.loopexit ], [ %split.ph3, %loop.exit.loopexit1 ]
62 bb9: ; preds = %bb9.loopexit, %bb1