1 ; RUN: opt -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]]], [2 x [3 x [5 x i16]]]* @x, i16 0, i64 undef
19 %_tmp126 = getelementptr [3 x [5 x i16]], [3 x [5 x i16]]* %_tmp123, i16 0, i64 %_tmp1423
20 %_tmp129 = getelementptr [5 x i16], [5 x i16]* %_tmp126, i16 0, i64 undef
21 %_tmp130 = load i16, i16* %_tmp129
22 store i16 undef, i16* getelementptr ([2 x [3 x [5 x i16]]], [2 x [3 x [5 x i16]]]* @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 = phi i16 [ undef, %bb6 ], [ undef, %bb6.lver.orig ]
32 bb9: ; preds = %bb9.loopexit, %bb1
36 ; CHECK-LABEL: @phi_with_non_loop_defined_value
37 define void @phi_with_non_loop_defined_value() {
38 bb6.lr.ph: ; preds = %bb5.preheader
42 bb6: ; preds = %bb6.lr.ph, %bb6
43 %_tmp1423 = phi i64 [ undef, %bb6.lr.ph ], [ %_tmp142, %bb6 ]
44 %_tmp123 = getelementptr [2 x [3 x [5 x i16]]], [2 x [3 x [5 x i16]]]* @x, i16 0, i64 undef
45 %_tmp126 = getelementptr [3 x [5 x i16]], [3 x [5 x i16]]* %_tmp123, i16 0, i64 %_tmp1423
46 %_tmp129 = getelementptr [5 x i16], [5 x i16]* %_tmp126, i16 0, i64 undef
47 %_tmp130 = load i16, i16* %_tmp129
48 store i16 undef, i16* getelementptr ([2 x [3 x [5 x i16]]], [2 x [3 x [5 x i16]]]* @x, i64 0, i64 undef, i64 undef, i64 undef)
49 %_tmp142 = add i64 %_tmp1423, 1
50 br i1 false, label %bb6, label %loop.exit
52 loop.exit: ; preds = %bb6
53 %_tmp142.lcssa = phi i64 [ %_tmp142, %bb6 ]
54 %split = phi i16 [ %t, %bb6 ]
55 ; CHECK: %split = phi i16 [ %t, %bb6 ], [ %t, %bb6.lver.orig ]
58 bb9: ; preds = %bb9.loopexit, %bb1