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.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 ] 32 br label %bb9 33 34bb9: ; preds = %bb9.loopexit, %bb1 35 ret void 36} 37 38; CHECK-LABEL: @phi_with_non_loop_defined_value 39define void @phi_with_non_loop_defined_value() { 40bb6.lr.ph: ; preds = %bb5.preheader 41 %t = add i16 1, 1 42 br label %bb6 43 44bb6: ; 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]]], [2 x [3 x [5 x i16]]]* @x, i16 0, i64 undef 47 %_tmp126 = getelementptr [3 x [5 x i16]], [3 x [5 x i16]]* %_tmp123, i16 0, i64 %_tmp1423 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 i64 %_tmp1423, 1 52 br i1 false, label %bb6, label %loop.exit 53 54loop.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 ] 60 br label %bb9 61 62bb9: ; preds = %bb9.loopexit, %bb1 63 ret void 64} 65