39 lines · plain
1; RUN: opt -S -loop-reduce < %s | FileCheck %s2; Scaling factor in addressing mode are costly.3; Make loop-reduce prefer unscaled accesses.4; <rdar://problem/13806271>5target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-n32:64-S128"6target triple = "arm64-apple-ios7.0.0"7 8; Function Attrs: nounwind ssp9define void @mulDouble(ptr nocapture %a, ptr nocapture %b, ptr nocapture %c) {10; CHECK: @mulDouble11entry:12 br label %for.body13 14for.body: ; preds = %for.body, %entry15; CHECK: [[IV:%[^ ]+]] = phi i64 [ [[IVNEXT:%[^,]+]], %for.body ], [ 0, %entry ]16; Only one induction variable should have been generated.17; CHECK-NOT: phi18 %indvars.iv = phi i64 [ 1, %entry ], [ %indvars.iv.next, %for.body ]19 %tmp = add nsw i64 %indvars.iv, -120 %arrayidx = getelementptr inbounds double, ptr %b, i64 %tmp21 %tmp1 = load double, ptr %arrayidx, align 822; The induction variable should carry the scaling factor: 1 * 8 = 8.23; CHECK: [[IVNEXT]] = add nuw nsw i64 [[IV]], 824 %indvars.iv.next = add i64 %indvars.iv, 125 %arrayidx2 = getelementptr inbounds double, ptr %c, i64 %indvars.iv.next26 %tmp2 = load double, ptr %arrayidx2, align 827 %mul = fmul double %tmp1, %tmp228 %arrayidx4 = getelementptr inbounds double, ptr %a, i64 %indvars.iv29 store double %mul, ptr %arrayidx4, align 830 %lftr.wideiv = trunc i64 %indvars.iv.next to i3231; Comparison should be 19 * 8 = 152.32; CHECK: icmp eq i32 {{%[^,]+}}, 15233 %exitcond = icmp eq i32 %lftr.wideiv, 2034 br i1 %exitcond, label %for.end, label %for.body35 36for.end: ; preds = %for.body37 ret void38}39