1; RUN: opt -loop-versioning -S < %s | FileCheck %s 2 3; Make sure all PHIs are properly updated in the exit block. Based on 4; PR28037. 5 6target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 7target triple = "x86_64-unknown-linux-gnu" 8 9@x = external global [2 x [3 x [5 x i16]]] 10 11; CHECK-LABEL: @phi_with_undef 12define void @phi_with_undef() { 13bb6.lr.ph: ; preds = %bb5.preheader 14 br label %bb6 15 16bb6: ; preds = %bb6.lr.ph, %bb6 17 %_tmp1423 = phi i16 [ 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 %_tmp125 = sext i16 %_tmp1423 to i64 20 %_tmp126 = getelementptr [3 x [5 x i16]], [3 x [5 x i16]]* %_tmp123, i16 0, i64 %_tmp125 21 %_tmp129 = getelementptr [5 x i16], [5 x i16]* %_tmp126, i16 0, i64 undef 22 %_tmp130 = load i16, i16* %_tmp129 23 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) 24 %_tmp142 = add i16 %_tmp1423, 1 25 br i1 false, label %bb6, label %loop.exit 26 27loop.exit: ; preds = %bb6 28 %_tmp142.lcssa = phi i16 [ %_tmp142, %bb6 ] 29 %split = phi i16 [ undef, %bb6 ] 30; CHECK: %split = phi i16 [ undef, %bb6 ], [ undef, %bb6.lver.orig ] 31 br label %bb9 32 33bb9: ; preds = %bb9.loopexit, %bb1 34 ret void 35} 36 37; CHECK-LABEL: @phi_with_non_loop_defined_value 38define void @phi_with_non_loop_defined_value() { 39bb6.lr.ph: ; preds = %bb5.preheader 40 %t = add i16 1, 1 41 br label %bb6 42 43bb6: ; preds = %bb6.lr.ph, %bb6 44 %_tmp1423 = phi i16 [ undef, %bb6.lr.ph ], [ %_tmp142, %bb6 ] 45 %_tmp123 = getelementptr [2 x [3 x [5 x i16]]], [2 x [3 x [5 x i16]]]* @x, i16 0, i64 undef 46 %_tmp125 = sext i16 %_tmp1423 to i64 47 %_tmp126 = getelementptr [3 x [5 x i16]], [3 x [5 x i16]]* %_tmp123, i16 0, i64 %_tmp125 48 %_tmp129 = getelementptr [5 x i16], [5 x i16]* %_tmp126, i16 0, i64 undef 49 %_tmp130 = load i16, i16* %_tmp129 50 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) 51 %_tmp142 = add i16 %_tmp1423, 1 52 br i1 false, label %bb6, label %loop.exit 53 54loop.exit: ; preds = %bb6 55 %_tmp142.lcssa = phi i16 [ %_tmp142, %bb6 ] 56 %split = phi i16 [ %t, %bb6 ] 57; CHECK: %split = phi i16 [ %t, %bb6 ], [ %t, %bb6.lver.orig ] 58 br label %bb9 59 60bb9: ; preds = %bb9.loopexit, %bb1 61 ret void 62} 63