brintos

brintos / llvm-project-archived public Read only

0
0
Text · 25.3 KiB · b3b25aa Raw
474 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: opt -mtriple=thumbv8.1m.main -mve-tail-predication -tail-predication=enabled -mattr=+mve,+lob %s -S -o - | FileCheck %s3 4; The following functions should all fail to become tail-predicated.5; CHECK-NOT: call i32 @llvm.arm.vctp6 7; trip.count.minus.1 has been inserted into element 1, not 0.8define dso_local arm_aapcs_vfpcc void @wrong_ph_insert_0(ptr noalias nocapture readonly %a, ptr noalias nocapture readonly %b, ptr noalias nocapture %c, i32 %N) {9entry:10  %cmp8 = icmp eq i32 %N, 011  %tmp8 = add i32 %N, 312  %tmp9 = lshr i32 %tmp8, 213  %tmp10 = shl nuw i32 %tmp9, 214  %tmp11 = add i32 %tmp10, -415  %tmp12 = lshr i32 %tmp11, 216  %tmp13 = add nuw nsw i32 %tmp12, 117  br i1 %cmp8, label %for.cond.cleanup, label %vector.ph18 19vector.ph:                                        ; preds = %entry20  %trip.count.minus.1 = add i32 %N, -121  %broadcast.splatinsert10 = insertelement <4 x i32> undef, i32 %trip.count.minus.1, i32 122  %broadcast.splat11 = shufflevector <4 x i32> %broadcast.splatinsert10, <4 x i32> undef, <4 x i32> zeroinitializer23  %start = call i32 @llvm.start.loop.iterations.i32(i32 %tmp13)24  br label %vector.body25 26vector.body:                                      ; preds = %vector.body, %vector.ph27  %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]28  %tmp14 = phi i32 [ %start, %vector.ph ], [ %tmp15, %vector.body ]29  %broadcast.splatinsert = insertelement <4 x i32> undef, i32 %index, i32 030  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> undef, <4 x i32> zeroinitializer31  %induction = add <4 x i32> %broadcast.splat, <i32 0, i32 1, i32 2, i32 3>32  %tmp = getelementptr inbounds i32, ptr %a, i32 %index33  %tmp1 = icmp ule <4 x i32> %induction, %broadcast.splat1134  %wide.masked.load = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp, i32 4, <4 x i1> %tmp1, <4 x i32> undef)35  %tmp3 = getelementptr inbounds i32, ptr %b, i32 %index36  %wide.masked.load12 = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp3, i32 4, <4 x i1> %tmp1, <4 x i32> undef)37  %tmp5 = mul nsw <4 x i32> %wide.masked.load12, %wide.masked.load38  %tmp6 = getelementptr inbounds i32, ptr %c, i32 %index39  tail call void @llvm.masked.store.v4i32.p0(<4 x i32> %tmp5, ptr %tmp6, i32 4, <4 x i1> %tmp1)40  %index.next = add i32 %index, 441  %tmp15 = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %tmp14, i32 1)42  %tmp16 = icmp ne i32 %tmp15, 043  br i1 %tmp16, label %vector.body, label %for.cond.cleanup44 45for.cond.cleanup:                                 ; preds = %vector.body, %entry46  ret void47}48 49; The insert isn't using an undef for operand 0.50define dso_local arm_aapcs_vfpcc void @wrong_ph_insert_def(ptr noalias nocapture readonly %a, ptr noalias nocapture readonly %b, ptr noalias nocapture %c, i32 %N) {51entry:52  %cmp8 = icmp eq i32 %N, 053  %tmp8 = add i32 %N, 354  %tmp9 = lshr i32 %tmp8, 255  %tmp10 = shl nuw i32 %tmp9, 256  %tmp11 = add i32 %tmp10, -457  %tmp12 = lshr i32 %tmp11, 258  %tmp13 = add nuw nsw i32 %tmp12, 159  br i1 %cmp8, label %for.cond.cleanup, label %vector.ph60 61vector.ph:                                        ; preds = %entry62  %trip.count.minus.1 = add i32 %N, -163  %broadcast.splatinsert10 = insertelement <4 x i32> <i32 1, i32 1, i32 1, i32 1>, i32 %trip.count.minus.1, i32 064  %broadcast.splat11 = shufflevector <4 x i32> %broadcast.splatinsert10, <4 x i32> undef, <4 x i32> zeroinitializer65  %start = call i32 @llvm.start.loop.iterations.i32(i32 %tmp13)66  br label %vector.body67 68vector.body:                                      ; preds = %vector.body, %vector.ph69  %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]70  %tmp14 = phi i32 [ %start, %vector.ph ], [ %tmp15, %vector.body ]71  %broadcast.splatinsert = insertelement <4 x i32> undef, i32 %index, i32 072  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> undef, <4 x i32> zeroinitializer73  %induction = add <4 x i32> %broadcast.splat, <i32 0, i32 1, i32 2, i32 3>74  %tmp = getelementptr inbounds i32, ptr %a, i32 %index75  %tmp1 = icmp ule <4 x i32> %induction, %broadcast.splat1176  %wide.masked.load = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp, i32 4, <4 x i1> %tmp1, <4 x i32> undef)77  %tmp3 = getelementptr inbounds i32, ptr %b, i32 %index78  %wide.masked.load12 = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp3, i32 4, <4 x i1> %tmp1, <4 x i32> undef)79  %tmp5 = mul nsw <4 x i32> %wide.masked.load12, %wide.masked.load80  %tmp6 = getelementptr inbounds i32, ptr %c, i32 %index81  tail call void @llvm.masked.store.v4i32.p0(<4 x i32> %tmp5, ptr %tmp6, i32 4, <4 x i1> %tmp1)82  %index.next = add i32 %index, 483  %tmp15 = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %tmp14, i32 1)84  %tmp16 = icmp ne i32 %tmp15, 085  br i1 %tmp16, label %vector.body, label %for.cond.cleanup86 87for.cond.cleanup:                                 ; preds = %vector.body, %entry88  ret void89}90 91; The shuffle uses a defined value for operand 1.92define dso_local arm_aapcs_vfpcc void @wrong_ph_shuffle_1(ptr noalias nocapture readonly %a, ptr noalias nocapture readonly %b, ptr noalias nocapture %c, i32 %N) {93entry:94  %cmp8 = icmp eq i32 %N, 095  %tmp8 = add i32 %N, 396  %tmp9 = lshr i32 %tmp8, 297  %tmp10 = shl nuw i32 %tmp9, 298  %tmp11 = add i32 %tmp10, -499  %tmp12 = lshr i32 %tmp11, 2100  %tmp13 = add nuw nsw i32 %tmp12, 1101  br i1 %cmp8, label %for.cond.cleanup, label %vector.ph102 103vector.ph:                                        ; preds = %entry104  %trip.count.minus.1 = add i32 %N, -1105  %broadcast.splatinsert10 = insertelement <4 x i32> undef, i32 %trip.count.minus.1, i32 0106  %broadcast.splat11 = shufflevector <4 x i32> %broadcast.splatinsert10, <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32> zeroinitializer107  %start = call i32 @llvm.start.loop.iterations.i32(i32 %tmp13)108  br label %vector.body109 110vector.body:                                      ; preds = %vector.body, %vector.ph111  %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]112  %tmp14 = phi i32 [ %start, %vector.ph ], [ %tmp15, %vector.body ]113  %broadcast.splatinsert = insertelement <4 x i32> undef, i32 %index, i32 0114  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> undef, <4 x i32> zeroinitializer115  %induction = add <4 x i32> %broadcast.splat, <i32 0, i32 1, i32 2, i32 3>116  %tmp = getelementptr inbounds i32, ptr %a, i32 %index117  %tmp1 = icmp ule <4 x i32> %induction, %broadcast.splat11118  %wide.masked.load = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp, i32 4, <4 x i1> %tmp1, <4 x i32> undef)119  %tmp3 = getelementptr inbounds i32, ptr %b, i32 %index120  %wide.masked.load12 = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp3, i32 4, <4 x i1> %tmp1, <4 x i32> undef)121  %tmp5 = mul nsw <4 x i32> %wide.masked.load12, %wide.masked.load122  %tmp6 = getelementptr inbounds i32, ptr %c, i32 %index123  tail call void @llvm.masked.store.v4i32.p0(<4 x i32> %tmp5, ptr %tmp6, i32 4, <4 x i1> %tmp1)124  %index.next = add i32 %index, 4125  %tmp15 = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %tmp14, i32 1)126  %tmp16 = icmp ne i32 %tmp15, 0127  br i1 %tmp16, label %vector.body, label %for.cond.cleanup128 129for.cond.cleanup:                                 ; preds = %vector.body, %entry130  ret void131}132 133; The shuffle uses a non zero value for operand 2.134define dso_local arm_aapcs_vfpcc void @wrong_ph_shuffle_2(ptr noalias nocapture readonly %a, ptr noalias nocapture readonly %b, ptr noalias nocapture %c, i32 %N) {135entry:136  %cmp8 = icmp eq i32 %N, 0137  %tmp8 = add i32 %N, 3138  %tmp9 = lshr i32 %tmp8, 2139  %tmp10 = shl nuw i32 %tmp9, 2140  %tmp11 = add i32 %tmp10, -4141  %tmp12 = lshr i32 %tmp11, 2142  %tmp13 = add nuw nsw i32 %tmp12, 1143  br i1 %cmp8, label %for.cond.cleanup, label %vector.ph144 145vector.ph:                                        ; preds = %entry146  %trip.count.minus.1 = add i32 %N, -1147  %broadcast.splatinsert10 = insertelement <4 x i32> undef, i32 %trip.count.minus.1, i32 0148  %broadcast.splat11 = shufflevector <4 x i32> %broadcast.splatinsert10, <4 x i32> undef, <4 x i32> <i32 1, i32 1, i32 1, i32 1>149  %start = call i32 @llvm.start.loop.iterations.i32(i32 %tmp13)150  br label %vector.body151 152vector.body:                                      ; preds = %vector.body, %vector.ph153  %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]154  %tmp14 = phi i32 [ %start, %vector.ph ], [ %tmp15, %vector.body ]155  %broadcast.splatinsert = insertelement <4 x i32> undef, i32 %index, i32 0156  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> undef, <4 x i32> zeroinitializer157  %induction = add <4 x i32> %broadcast.splat, <i32 0, i32 1, i32 2, i32 3>158  %tmp = getelementptr inbounds i32, ptr %a, i32 %index159  %tmp1 = icmp ule <4 x i32> %induction, %broadcast.splat11160  %wide.masked.load = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp, i32 4, <4 x i1> %tmp1, <4 x i32> undef)161  %tmp3 = getelementptr inbounds i32, ptr %b, i32 %index162  %wide.masked.load12 = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp3, i32 4, <4 x i1> %tmp1, <4 x i32> undef)163  %tmp5 = mul nsw <4 x i32> %wide.masked.load12, %wide.masked.load164  %tmp6 = getelementptr inbounds i32, ptr %c, i32 %index165  tail call void @llvm.masked.store.v4i32.p0(<4 x i32> %tmp5, ptr %tmp6, i32 4, <4 x i1> %tmp1)166  %index.next = add i32 %index, 4167  %tmp15 = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %tmp14, i32 1)168  %tmp16 = icmp ne i32 %tmp15, 0169  br i1 %tmp16, label %vector.body, label %for.cond.cleanup170 171for.cond.cleanup:                                 ; preds = %vector.body, %entry172  ret void173}174 175; %N - 2176define dso_local arm_aapcs_vfpcc void @trip_count_minus_2(ptr noalias nocapture readonly %a, ptr noalias nocapture readonly %b, ptr noalias nocapture %c, i32 %N) {177entry:178  %cmp8 = icmp eq i32 %N, 0179  %tmp8 = add i32 %N, 3180  %tmp9 = lshr i32 %tmp8, 2181  %tmp10 = shl nuw i32 %tmp9, 2182  %tmp11 = add i32 %tmp10, -4183  %tmp12 = lshr i32 %tmp11, 2184  %tmp13 = add nuw nsw i32 %tmp12, 1185  br i1 %cmp8, label %for.cond.cleanup, label %vector.ph186 187vector.ph:                                        ; preds = %entry188  %trip.count.minus.2 = add i32 %N, -2189  %broadcast.splatinsert10 = insertelement <4 x i32> undef, i32 %trip.count.minus.2, i32 1190  %broadcast.splat11 = shufflevector <4 x i32> %broadcast.splatinsert10, <4 x i32> undef, <4 x i32> zeroinitializer191  %start = call i32 @llvm.start.loop.iterations.i32(i32 %tmp13)192  br label %vector.body193 194vector.body:                                      ; preds = %vector.body, %vector.ph195  %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]196  %tmp14 = phi i32 [ %start, %vector.ph ], [ %tmp15, %vector.body ]197  %broadcast.splatinsert = insertelement <4 x i32> undef, i32 %index, i32 0198  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> undef, <4 x i32> zeroinitializer199  %induction = add <4 x i32> %broadcast.splat, <i32 0, i32 1, i32 2, i32 3>200  %tmp = getelementptr inbounds i32, ptr %a, i32 %index201  %tmp1 = icmp ule <4 x i32> %induction, %broadcast.splat11202  %wide.masked.load = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp, i32 4, <4 x i1> %tmp1, <4 x i32> undef)203  %tmp3 = getelementptr inbounds i32, ptr %b, i32 %index204  %wide.masked.load12 = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp3, i32 4, <4 x i1> %tmp1, <4 x i32> undef)205  %tmp5 = mul nsw <4 x i32> %wide.masked.load12, %wide.masked.load206  %tmp6 = getelementptr inbounds i32, ptr %c, i32 %index207  tail call void @llvm.masked.store.v4i32.p0(<4 x i32> %tmp5, ptr %tmp6, i32 4, <4 x i1> %tmp1)208  %index.next = add i32 %index, 4209  %tmp15 = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %tmp14, i32 1)210  %tmp16 = icmp ne i32 %tmp15, 0211  br i1 %tmp16, label %vector.body, label %for.cond.cleanup212 213for.cond.cleanup:                                 ; preds = %vector.body, %entry214  ret void215}216 217; index has been inserted at element 1, not 0.218define dso_local arm_aapcs_vfpcc void @wrong_loop_insert(ptr noalias nocapture readonly %a, ptr noalias nocapture readonly %b, ptr noalias nocapture %c, i32 %N) {219entry:220  %cmp8 = icmp eq i32 %N, 0221  %tmp8 = add i32 %N, 3222  %tmp9 = lshr i32 %tmp8, 2223  %tmp10 = shl nuw i32 %tmp9, 2224  %tmp11 = add i32 %tmp10, -4225  %tmp12 = lshr i32 %tmp11, 2226  %tmp13 = add nuw nsw i32 %tmp12, 1227  br i1 %cmp8, label %for.cond.cleanup, label %vector.ph228 229vector.ph:                                        ; preds = %entry230  %trip.count.minus.1 = add i32 %N, -1231  %broadcast.splatinsert10 = insertelement <4 x i32> undef, i32 %trip.count.minus.1, i32 0232  %broadcast.splat11 = shufflevector <4 x i32> %broadcast.splatinsert10, <4 x i32> undef, <4 x i32> zeroinitializer233  %start = call i32 @llvm.start.loop.iterations.i32(i32 %tmp13)234  br label %vector.body235 236vector.body:                                      ; preds = %vector.body, %vector.ph237  %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]238  %tmp14 = phi i32 [ %start, %vector.ph ], [ %tmp15, %vector.body ]239  %broadcast.splatinsert = insertelement <4 x i32> undef, i32 %index, i32 1240  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> undef, <4 x i32> zeroinitializer241  %induction = add <4 x i32> %broadcast.splat, <i32 0, i32 1, i32 2, i32 3>242  %tmp = getelementptr inbounds i32, ptr %a, i32 %index243  %tmp1 = icmp ule <4 x i32> %induction, %broadcast.splat11244  %wide.masked.load = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp, i32 4, <4 x i1> %tmp1, <4 x i32> undef)245  %tmp3 = getelementptr inbounds i32, ptr %b, i32 %index246  %wide.masked.load12 = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp3, i32 4, <4 x i1> %tmp1, <4 x i32> undef)247  %tmp5 = mul nsw <4 x i32> %wide.masked.load12, %wide.masked.load248  %tmp6 = getelementptr inbounds i32, ptr %c, i32 %index249  tail call void @llvm.masked.store.v4i32.p0(<4 x i32> %tmp5, ptr %tmp6, i32 4, <4 x i1> %tmp1)250  %index.next = add i32 %index, 4251  %tmp15 = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %tmp14, i32 1)252  %tmp16 = icmp ne i32 %tmp15, 0253  br i1 %tmp16, label %vector.body, label %for.cond.cleanup254 255for.cond.cleanup:                                 ; preds = %vector.body, %entry256  ret void257}258 259define dso_local arm_aapcs_vfpcc void @wrong_loop_invalid_index_splat(ptr noalias nocapture readonly %a, ptr noalias nocapture readonly %b, ptr noalias nocapture %c, i32 %N) {260entry:261  %cmp8 = icmp eq i32 %N, 0262  %tmp8 = add i32 %N, 3263  %tmp9 = lshr i32 %tmp8, 2264  %tmp10 = shl nuw i32 %tmp9, 2265  %tmp11 = add i32 %tmp10, -4266  %tmp12 = lshr i32 %tmp11, 2267  %tmp13 = add nuw nsw i32 %tmp12, 1268  br i1 %cmp8, label %for.cond.cleanup, label %vector.ph269 270vector.ph:                                        ; preds = %entry271  %trip.count.minus.1 = add i32 %N, -1272  %broadcast.splatinsert10 = insertelement <4 x i32> undef, i32 %trip.count.minus.1, i32 0273  %broadcast.splat11 = shufflevector <4 x i32> %broadcast.splatinsert10, <4 x i32> undef, <4 x i32> zeroinitializer274  %start = call i32 @llvm.start.loop.iterations.i32(i32 %tmp13)275  br label %vector.body276 277vector.body:                                      ; preds = %vector.body, %vector.ph278  %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]279  %tmp14 = phi i32 [ %start, %vector.ph ], [ %tmp15, %vector.body ]280  %incorrect = add i32 %index, 1281  %broadcast.splatinsert = insertelement <4 x i32> undef, i32 %incorrect, i32 0282  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> undef, <4 x i32> zeroinitializer283  %induction = add <4 x i32> %broadcast.splat, <i32 0, i32 1, i32 2, i32 3>284  %tmp = getelementptr inbounds i32, ptr %a, i32 %index285  %tmp1 = icmp ule <4 x i32> %induction, %broadcast.splat11286  %wide.masked.load = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp, i32 4, <4 x i1> %tmp1, <4 x i32> undef)287  %tmp3 = getelementptr inbounds i32, ptr %b, i32 %index288  %wide.masked.load12 = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp3, i32 4, <4 x i1> %tmp1, <4 x i32> undef)289  %tmp5 = mul nsw <4 x i32> %wide.masked.load12, %wide.masked.load290  %tmp6 = getelementptr inbounds i32, ptr %c, i32 %index291  tail call void @llvm.masked.store.v4i32.p0(<4 x i32> %tmp5, ptr %tmp6, i32 4, <4 x i1> %tmp1)292  %index.next = add i32 %index, 4293  %tmp15 = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %tmp14, i32 1)294  %tmp16 = icmp ne i32 %tmp15, 0295  br i1 %tmp16, label %vector.body, label %for.cond.cleanup296 297for.cond.cleanup:                                 ; preds = %vector.body, %entry298  ret void299}300 301; Now using ult, not ule for the vector icmp302define dso_local arm_aapcs_vfpcc void @wrong_pred_opcode(ptr noalias nocapture readonly %a, ptr noalias nocapture readonly %b, ptr noalias nocapture %c, i32 %N) {303entry:304  %cmp8 = icmp eq i32 %N, 0305  %tmp8 = add i32 %N, 3306  %tmp9 = lshr i32 %tmp8, 2307  %tmp10 = shl nuw i32 %tmp9, 2308  %tmp11 = add i32 %tmp10, -4309  %tmp12 = lshr i32 %tmp11, 2310  %tmp13 = add nuw nsw i32 %tmp12, 1311  br i1 %cmp8, label %for.cond.cleanup, label %vector.ph312 313vector.ph:                                        ; preds = %entry314  %trip.count.minus.1 = add i32 %N, -1315  %broadcast.splatinsert10 = insertelement <4 x i32> undef, i32 %trip.count.minus.1, i32 0316  %broadcast.splat11 = shufflevector <4 x i32> %broadcast.splatinsert10, <4 x i32> undef, <4 x i32> zeroinitializer317  %start = call i32 @llvm.start.loop.iterations.i32(i32 %tmp13)318  br label %vector.body319 320vector.body:                                      ; preds = %vector.body, %vector.ph321  %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]322  %tmp14 = phi i32 [ %start, %vector.ph ], [ %tmp15, %vector.body ]323  %broadcast.splatinsert = insertelement <4 x i32> undef, i32 %index, i32 0324  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> undef, <4 x i32> zeroinitializer325  %induction = add <4 x i32> %broadcast.splat, <i32 0, i32 1, i32 2, i32 3>326  %tmp = getelementptr inbounds i32, ptr %a, i32 %index327  %tmp1 = icmp ult <4 x i32> %induction, %broadcast.splat11328  %wide.masked.load = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp, i32 4, <4 x i1> %tmp1, <4 x i32> undef)329  %tmp3 = getelementptr inbounds i32, ptr %b, i32 %index330  %wide.masked.load12 = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp3, i32 4, <4 x i1> %tmp1, <4 x i32> undef)331  %tmp5 = mul nsw <4 x i32> %wide.masked.load12, %wide.masked.load332  %tmp6 = getelementptr inbounds i32, ptr %c, i32 %index333  tail call void @llvm.masked.store.v4i32.p0(<4 x i32> %tmp5, ptr %tmp6, i32 4, <4 x i1> %tmp1)334  %index.next = add i32 %index, 4335  %tmp15 = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %tmp14, i32 1)336  %tmp16 = icmp ne i32 %tmp15, 0337  br i1 %tmp16, label %vector.body, label %for.cond.cleanup338 339for.cond.cleanup:                                 ; preds = %vector.body, %entry340  ret void341}342 343; The add in the body uses 1, 2, 3, 4344define void @wrong_body_broadcast_splat(ptr noalias nocapture readonly %a, ptr noalias nocapture readonly %b, ptr noalias nocapture %c, i32 %N) {345entry:346  %cmp8 = icmp eq i32 %N, 0347  %tmp8 = add i32 %N, 3348  %tmp9 = lshr i32 %tmp8, 2349  %tmp10 = shl nuw i32 %tmp9, 2350  %tmp11 = add i32 %tmp10, -4351  %tmp12 = lshr i32 %tmp11, 2352  %tmp13 = add nuw nsw i32 %tmp12, 1353  br i1 %cmp8, label %for.cond.cleanup, label %vector.ph354 355vector.ph:                                        ; preds = %entry356  %trip.count.minus.1 = add i32 %N, -1357  %broadcast.splatinsert10 = insertelement <4 x i32> undef, i32 %trip.count.minus.1, i32 0358  %broadcast.splat11 = shufflevector <4 x i32> %broadcast.splatinsert10, <4 x i32> undef, <4 x i32> zeroinitializer359  %start = call i32 @llvm.start.loop.iterations.i32(i32 %tmp13)360  br label %vector.body361 362vector.body:                                      ; preds = %vector.body, %vector.ph363  %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]364  %tmp14 = phi i32 [ %start, %vector.ph ], [ %tmp15, %vector.body ]365  %broadcast.splatinsert = insertelement <4 x i32> undef, i32 %index, i32 0366  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> undef, <4 x i32> zeroinitializer367  %induction = add <4 x i32> %broadcast.splat, <i32 1, i32 2, i32 3, i32 4>368  %tmp = getelementptr inbounds i32, ptr %a, i32 %index369  %tmp1 = icmp ule <4 x i32> %induction, %broadcast.splat11370  %wide.masked.load = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp, i32 4, <4 x i1> %tmp1, <4 x i32> undef)371  %tmp3 = getelementptr inbounds i32, ptr %b, i32 %index372  %wide.masked.load12 = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp3, i32 4, <4 x i1> %tmp1, <4 x i32> undef)373  %tmp5 = mul nsw <4 x i32> %wide.masked.load12, %wide.masked.load374  %tmp6 = getelementptr inbounds i32, ptr %c, i32 %index375  tail call void @llvm.masked.store.v4i32.p0(<4 x i32> %tmp5, ptr %tmp6, i32 4, <4 x i1> %tmp1)376  %index.next = add i32 %index, 4377  %tmp15 = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %tmp14, i32 1)378  %tmp16 = icmp ne i32 %tmp15, 0379  br i1 %tmp16, label %vector.body, label %for.cond.cleanup380 381for.cond.cleanup:                                 ; preds = %vector.body, %entry382  ret void383}384 385; Using a variable for the loop body broadcast.386define void @wrong_body_broadcast_splat_2(ptr noalias nocapture readonly %a, ptr noalias nocapture readonly %b, ptr noalias nocapture %c, i32 %N, <4 x i32> %offsets) {387entry:388  %cmp8 = icmp eq i32 %N, 0389  %tmp8 = add i32 %N, 3390  %tmp9 = lshr i32 %tmp8, 2391  %tmp10 = shl nuw i32 %tmp9, 2392  %tmp11 = add i32 %tmp10, -4393  %tmp12 = lshr i32 %tmp11, 2394  %tmp13 = add nuw nsw i32 %tmp12, 1395  br i1 %cmp8, label %for.cond.cleanup, label %vector.ph396 397vector.ph:                                        ; preds = %entry398  %trip.count.minus.1 = add i32 %N, -1399  %broadcast.splatinsert10 = insertelement <4 x i32> undef, i32 %trip.count.minus.1, i32 0400  %broadcast.splat11 = shufflevector <4 x i32> %broadcast.splatinsert10, <4 x i32> undef, <4 x i32> zeroinitializer401  %start = call i32 @llvm.start.loop.iterations.i32(i32 %tmp13)402  br label %vector.body403 404vector.body:                                      ; preds = %vector.body, %vector.ph405  %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]406  %tmp14 = phi i32 [ %start, %vector.ph ], [ %tmp15, %vector.body ]407  %broadcast.splatinsert = insertelement <4 x i32> undef, i32 %index, i32 0408  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> undef, <4 x i32> zeroinitializer409  %induction = add <4 x i32> %broadcast.splat, %offsets410  %tmp = getelementptr inbounds i32, ptr %a, i32 %index411  %tmp1 = icmp ule <4 x i32> %induction, %broadcast.splat11412  %wide.masked.load = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp, i32 4, <4 x i1> %tmp1, <4 x i32> undef)413  %tmp3 = getelementptr inbounds i32, ptr %b, i32 %index414  %wide.masked.load12 = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp3, i32 4, <4 x i1> %tmp1, <4 x i32> undef)415  %tmp5 = mul nsw <4 x i32> %wide.masked.load12, %wide.masked.load416  %tmp6 = getelementptr inbounds i32, ptr %c, i32 %index417  tail call void @llvm.masked.store.v4i32.p0(<4 x i32> %tmp5, ptr %tmp6, i32 4, <4 x i1> %tmp1)418  %index.next = add i32 %index, 4419  %tmp15 = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %tmp14, i32 1)420  %tmp16 = icmp ne i32 %tmp15, 0421  br i1 %tmp16, label %vector.body, label %for.cond.cleanup422 423for.cond.cleanup:                                 ; preds = %vector.body, %entry424  ret void425}426 427; adding 5, instead of 4, to index.428define void @wrong_index_add(ptr noalias nocapture readonly %a, ptr noalias nocapture readonly %b, ptr noalias nocapture %c, i32 %N) {429entry:430  %cmp8 = icmp eq i32 %N, 0431  %tmp8 = add i32 %N, 3432  %tmp9 = lshr i32 %tmp8, 2433  %tmp10 = shl nuw i32 %tmp9, 2434  %tmp11 = add i32 %tmp10, -4435  %tmp12 = lshr i32 %tmp11, 2436  %tmp13 = add nuw nsw i32 %tmp12, 1437  br i1 %cmp8, label %for.cond.cleanup, label %vector.ph438 439vector.ph:                                        ; preds = %entry440  %trip.count.minus.1 = add i32 %N, -1441  %broadcast.splatinsert10 = insertelement <4 x i32> undef, i32 %trip.count.minus.1, i32 0442  %broadcast.splat11 = shufflevector <4 x i32> %broadcast.splatinsert10, <4 x i32> undef, <4 x i32> zeroinitializer443  %start = call i32 @llvm.start.loop.iterations.i32(i32 %tmp13)444  br label %vector.body445 446vector.body:                                      ; preds = %vector.body, %vector.ph447  %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]448  %tmp14 = phi i32 [ %start, %vector.ph ], [ %tmp15, %vector.body ]449  %broadcast.splatinsert = insertelement <4 x i32> undef, i32 %index, i32 0450  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> undef, <4 x i32> zeroinitializer451  %induction = add <4 x i32> %broadcast.splat, <i32 0, i32 1, i32 2, i32 3>452  %tmp = getelementptr inbounds i32, ptr %a, i32 %index453  %tmp1 = icmp ule <4 x i32> %induction, %broadcast.splat11454  %wide.masked.load = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp, i32 4, <4 x i1> %tmp1, <4 x i32> undef)455  %tmp3 = getelementptr inbounds i32, ptr %b, i32 %index456  %wide.masked.load12 = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp3, i32 4, <4 x i1> %tmp1, <4 x i32> undef)457  %tmp5 = mul nsw <4 x i32> %wide.masked.load12, %wide.masked.load458  %tmp6 = getelementptr inbounds i32, ptr %c, i32 %index459  tail call void @llvm.masked.store.v4i32.p0(<4 x i32> %tmp5, ptr %tmp6, i32 4, <4 x i1> %tmp1)460  %index.next = add i32 %index, 5461  %tmp15 = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 %tmp14, i32 1)462  %tmp16 = icmp ne i32 %tmp15, 0463  br i1 %tmp16, label %vector.body, label %for.cond.cleanup464 465for.cond.cleanup:                                 ; preds = %vector.body, %entry466  ret void467}468 469declare <4 x i32> @llvm.masked.load.v4i32.p0(ptr, i32 immarg, <4 x i1>, <4 x i32>) #1470declare void @llvm.masked.store.v4i32.p0(<4 x i32>, ptr, i32 immarg, <4 x i1>) #2471declare i32 @llvm.start.loop.iterations.i32(i32) #3472declare i32 @llvm.loop.decrement.reg.i32.i32.i32(i32, i32) #3473 474