1; RUN: opt < %s -basicaa -slp-vectorizer -S 2 3target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 4target triple = "x86_64-apple-macosx10.10.0" 5 6define void @testfunc(float* nocapture %dest, float* nocapture readonly %src) { 7entry: 8 br label %for.body 9 10for.body: 11 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] 12 %acc1.056 = phi float [ 0.000000e+00, %entry ], [ %add13, %for.body ] 13 %s1.055 = phi float [ 0.000000e+00, %entry ], [ %cond.i40, %for.body ] 14 %s0.054 = phi float [ 0.000000e+00, %entry ], [ %cond.i44, %for.body ] 15 %arrayidx = getelementptr inbounds float, float* %src, i64 %indvars.iv 16 %0 = load float, float* %arrayidx, align 4 17 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 18 %arrayidx2 = getelementptr inbounds float, float* %dest, i64 %indvars.iv 19 store float %acc1.056, float* %arrayidx2, align 4 20 %add = fadd float %s0.054, %0 21 %add3 = fadd float %s1.055, %0 22 %mul = fmul float %s0.054, 0.000000e+00 23 %add4 = fadd float %mul, %add3 24 %mul5 = fmul float %s1.055, 0.000000e+00 25 %add6 = fadd float %mul5, %add 26 %cmp.i = fcmp olt float %add6, 1.000000e+00 27 %cond.i = select i1 %cmp.i, float %add6, float 1.000000e+00 28 %cmp.i51 = fcmp olt float %cond.i, -1.000000e+00 29 %cmp.i49 = fcmp olt float %add4, 1.000000e+00 30 %cond.i50 = select i1 %cmp.i49, float %add4, float 1.000000e+00 31 %cmp.i47 = fcmp olt float %cond.i50, -1.000000e+00 32 %cond.i.op = fmul float %cond.i, 0.000000e+00 33 %mul10 = select i1 %cmp.i51, float -0.000000e+00, float %cond.i.op 34 %cond.i50.op = fmul float %cond.i50, 0.000000e+00 35 %mul11 = select i1 %cmp.i47, float -0.000000e+00, float %cond.i50.op 36 %add13 = fadd float %mul10, %mul11 37 38 ; The SLPVectorizer crashed in vectorizeChainsInBlock() because it tried 39 ; to access the second operand of the following cmp after the cmp itself 40 ; was already vectorized and deleted. 41 %cmp.i45 = fcmp olt float %add13, 1.000000e+00 42 43 %cond.i46 = select i1 %cmp.i45, float %add13, float 1.000000e+00 44 %cmp.i43 = fcmp olt float %cond.i46, -1.000000e+00 45 %cond.i44 = select i1 %cmp.i43, float -1.000000e+00, float %cond.i46 46 %cmp.i41 = fcmp olt float %mul11, 1.000000e+00 47 %cond.i42 = select i1 %cmp.i41, float %mul11, float 1.000000e+00 48 %cmp.i39 = fcmp olt float %cond.i42, -1.000000e+00 49 %cond.i40 = select i1 %cmp.i39, float -1.000000e+00, float %cond.i42 50 %exitcond = icmp eq i64 %indvars.iv.next, 32 51 br i1 %exitcond, label %for.end, label %for.body 52 53for.end: 54 ret void 55} 56 57