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 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 25 26loop.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 ] 30 br label %bb9 31 32bb9: ; preds = %bb9.loopexit, %bb1 33 ret void 34} 35 36; CHECK-LABEL: @phi_with_non_loop_defined_value 37define void @phi_with_non_loop_defined_value() { 38bb6.lr.ph: ; preds = %bb5.preheader 39 %t = add i16 1, 1 40 br label %bb6 41 42bb6: ; 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 51 52loop.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 ] 56 br label %bb9 57 58bb9: ; preds = %bb9.loopexit, %bb1 59 ret void 60} 61