1 ; RUN: opt -S -indvars < %s | FileCheck %s 2 3 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 4 target triple = "x86_64-apple-macosx10.11.0" 5 6 ; SCEVExpander would try to RAUW %val_2 with %c.lcssa, breaking "def 7 ; dominates uses". 8 9 define void @pr27232(i32 %val) { 10 ; CHECK-LABEL: @pr27232( 11 entry: 12 br i1 undef, label %loop_0.cond, label %for.body.us 13 14 for.body.us: 15 br label %loop_0.cond 16 17 loop_0.cond: 18 %val_2 = phi i32 [ %val, %for.body.us ], [ undef, %entry ] 19 br i1 true, label %loop_0.ph, label %loop_1.ph 20 21 loop_0.ph: 22 br label %loop_0 23 24 loop_1.exit: 25 br label %loop_1.ph 26 27 loop_1.ph: 28 %c.lcssa = phi i32 [ 0, %loop_0.cond ], [ %val_2, %loop_1.exit ] 29 br label %loop_1 30 31 loop_0: 32 br i1 undef, label %loop_0, label %loop_1.exit 33 34 loop_1: 35 %d.1 = phi i32 [ %c.lcssa, %loop_1 ], [ %val_2, %loop_1.ph ] 36 %t.1 = phi i32 [ %val_2, %loop_1 ], [ %c.lcssa, %loop_1.ph ] 37 br i1 undef, label %leave, label %loop_1 38 39 leave: 40 ret void 41 } 42 43 44 ; @ReplaceArg_0 and @ReplaceArg_1 used to trigger a failed cast<> 45 ; assertion in SCEVExpander. 46 47 define void @ReplaceArg_0(i32 %val) { 48 ; CHECK-LABEL: @ReplaceArg_0( 49 entry: 50 br i1 undef, label %loop_0.cond, label %for.body.us 51 52 for.body.us: 53 br label %loop_0.cond 54 55 loop_0.cond: 56 br i1 true, label %loop_0.ph, label %loop_1.ph 57 58 loop_0.ph: 59 br label %loop_0 60 61 loop_1.exit: 62 br label %loop_1.ph 63 64 loop_1.ph: 65 %c.lcssa = phi i32 [ 0, %loop_0.cond ], [ %val, %loop_1.exit ] 66 br label %loop_1 67 68 loop_0: 69 br i1 undef, label %loop_0, label %loop_1.exit 70 71 loop_1: 72 %d.1 = phi i32 [ %c.lcssa, %loop_1 ], [ %val, %loop_1.ph ] 73 %t.1 = phi i32 [ %val, %loop_1 ], [ %c.lcssa, %loop_1.ph ] 74 br i1 undef, label %leave, label %loop_1 75 76 leave: 77 ret void 78 } 79 80 define void @ReplaceArg_1(i32 %val) { 81 ; CHECK-LABEL: @ReplaceArg_1( 82 entry: 83 br i1 undef, label %loop_0.cond, label %for.body.us 84 85 for.body.us: 86 br label %loop_0.cond 87 88 loop_0.cond: 89 br i1 true, label %loop_0.ph, label %loop_1.ph 90 91 loop_0.ph: 92 br label %loop_0 93 94 loop_1.exit: 95 br label %loop_1.ph 96 97 loop_1.ph: 98 %c.lcssa = phi i32 [ 0, %loop_0.cond ], [ %val, %loop_1.exit ] 99 br label %loop_1 100 101 loop_0: 102 br i1 undef, label %loop_0, label %loop_1.exit 103 104 loop_1: 105 %t.1 = phi i32 [ %val, %loop_1 ], [ %c.lcssa, %loop_1.ph ] 106 %d.1 = phi i32 [ %c.lcssa, %loop_1 ], [ %val, %loop_1.ph ] 107 br i1 undef, label %leave, label %loop_1 108 109 leave: 110 ret void 111 } 112