brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.0 KiB · 5948387 Raw
73 lines · plain
1; RUN: opt < %s  -passes="print<cost-model>" 2>&1 -disable-output -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx | FileCheck %s2 3target 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-s0:64:64-f80:128:128-n8:16:32:64-S128"4target triple = "x86_64-apple-macosx10.8.0"5 6define i32 @foo(ptr noalias nocapture %A, ptr noalias nocapture %B, i32 %start, i32 %end) nounwind uwtable ssp {7entry:8  ;CHECK: cost of 1 {{.*}} icmp9  %cmp7 = icmp slt i32 %start, %end10  br i1 %cmp7, label %for.body.lr.ph, label %for.end11 12for.body.lr.ph:                                   ; preds = %entry13  ;CHECK: cost of 1 {{.*}} sext14  %0 = sext i32 %start to i6415  %1 = sub i32 %end, %start16  %2 = zext i32 %1 to i6417  %end.idx = add i64 %2, %018  ;CHECK: cost of 1 {{.*}} add19  %n.vec = and i64 %2, 429496728820  %end.idx.rnd.down = add i64 %n.vec, %021  ;CHECK: cost of 1 {{.*}} icmp22  %cmp.zero = icmp eq i64 %n.vec, 023  br i1 %cmp.zero, label %middle.block, label %vector.body24 25vector.body:                                      ; preds = %for.body.lr.ph, %vector.body26  %index = phi i64 [ %index.next, %vector.body ], [ %0, %for.body.lr.ph ]27  %3 = add i64 %index, 228  %4 = getelementptr inbounds i32, ptr %B, i64 %329  ;CHECK: cost of 2 {{.*}} load30  %5 = load <8 x i32>, ptr %4, align 431  ;CHECK: cost of 5 {{.*}} mul32  %6 = mul nsw <8 x i32> %5, <i32 5, i32 5, i32 5, i32 5, i32 5, i32 5, i32 5, i32 5>33  %7 = getelementptr inbounds i32, ptr %A, i64 %index34  ;CHECK: cost of 2 {{.*}} load35  %8 = load <8 x i32>, ptr %7, align 436  ;CHECK: cost of 4 {{.*}} add37  %9 = add nsw <8 x i32> %8, %638  ;CHECK: cost of 2 {{.*}} store39  store <8 x i32> %9, ptr %7, align 440  %index.next = add i64 %index, 841  %10 = icmp eq i64 %index.next, %end.idx.rnd.down42  ;CHECK: cost of 0 {{.*}} br43  br i1 %10, label %middle.block, label %vector.body44 45middle.block:                                     ; preds = %vector.body, %for.body.lr.ph46  %cmp.n = icmp eq i64 %end.idx, %end.idx.rnd.down47  br i1 %cmp.n, label %for.end, label %for.body48 49for.body:                                         ; preds = %middle.block, %for.body50  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ %end.idx.rnd.down, %middle.block ]51  %11 = add nsw i64 %indvars.iv, 252  %arrayidx = getelementptr inbounds i32, ptr %B, i64 %1153  ;CHECK: cost of 1 {{.*}} load54  %12 = load i32, ptr %arrayidx, align 455  ;CHECK: cost of 1 {{.*}} mul56  %mul = mul nsw i32 %12, 557  %arrayidx2 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv58  ;CHECK: cost of 1 {{.*}} load59  %13 = load i32, ptr %arrayidx2, align 460  %add3 = add nsw i32 %13, %mul61  store i32 %add3, ptr %arrayidx2, align 462  %indvars.iv.next = add i64 %indvars.iv, 163  ;CHECK: cost of 0 {{.*}} trunc64  %14 = trunc i64 %indvars.iv.next to i3265  %cmp = icmp slt i32 %14, %end66  ;CHECK: cost of 0 {{.*}} br67  br i1 %cmp, label %for.body, label %for.end68 69for.end:                                          ; preds = %middle.block, %for.body, %entry70  ;CHECK: cost of 0 {{.*}} ret71  ret i32 undef72}73