2016-03-27 11 views
3

Ich habe folgende IR:Warum programmiert LLVM diesen Code nicht SIMD?

; ModuleID = 'vec.ir' 
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 
target triple = "x86_64-apple-darwin15.3.0" 

define void @patch(i64) { 
entry: 
    %1 = load float, float* inttoptr (i64 4388240000 to float*) 
    %2 = load float, float* inttoptr (i64 4387644544 to float*) 
    %3 = fadd float %1, %2 
    %4 = load float, float* inttoptr (i64 4387729024 to float*) 
    %5 = fadd float %1, %4 
    %6 = load float, float* inttoptr (i64 4387730560 to float*) 
    %7 = fadd float %1, %6 
    %8 = load float, float* inttoptr (i64 4387513984 to float*) 
    %9 = fadd float %1, %8 
    store float %3, float* inttoptr (i64 4371309760 to float*) 
    call void @__tickValue(i64 105553117467608, i64 %0) 
    store float %5, float* inttoptr (i64 4371851456 to float*) 
    call void @__tickValue(i64 105553117465688, i64 %0) 
    store float %7, float* inttoptr (i64 4371574976 to float*) 
    call void @__tickValue(i64 105553117465528, i64 %0) 
    store float %9, float* inttoptr (i64 4371576512 to float*) 
    call void @__tickValue(i64 105553117466648, i64 %0) 
    ret void 
} 

declare void @__tickValue(i64, i64) 

Als ich /usr/local/opt/llvm/bin/opt -S -O3 vec.ir > vec-opt.ir laufen, erhalte ich:

; ModuleID = 'vec.ir' 
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 
target triple = "x86_64-apple-darwin15.3.0" 

define void @patch(i64) { 
entry: 
    %1 = load float, float* inttoptr (i64 4388240000 to float*), align 128 
    %2 = load float, float* inttoptr (i64 4387644544 to float*), align 128 
    %3 = fadd float %1, %2 
    %4 = load float, float* inttoptr (i64 4387729024 to float*), align 128 
    %5 = fadd float %1, %4 
    %6 = load float, float* inttoptr (i64 4387730560 to float*), align 128 
    %7 = fadd float %1, %6 
    %8 = load float, float* inttoptr (i64 4387513984 to float*), align 128 
    %9 = fadd float %1, %8 
    store float %3, float* inttoptr (i64 4371309760 to float*), align 64 
    tail call void @__tickValue(i64 105553117467608, i64 %0) 
    store float %5, float* inttoptr (i64 4371851456 to float*), align 64 
    tail call void @__tickValue(i64 105553117465688, i64 %0) 
    store float %7, float* inttoptr (i64 4371574976 to float*), align 64 
    tail call void @__tickValue(i64 105553117465528, i64 %0) 
    store float %9, float* inttoptr (i64 4371576512 to float*), align 64 
    tail call void @__tickValue(i64 105553117466648, i64 %0) 
    ret void 
} 

declare void @__tickValue(i64, i64) 

Per http://llvm.org/docs/Vectorizers.html#the-slp-vectorizer, ich hatte gehofft, dass die fadd Anweisungen würde kombiniert werden.

Wie kann ich mehr Informationen darüber finden, warum der Optimierer nicht vektorisiert?

Antwort

2

LLVM hat interne Kostenmodelle, die automatisch erkennen, ob die SIMD-Vektorisierung vorteilhaft ist. Sie können Diagnoseinformationen von adding some flags to your build line

haben Sie können auch versuchen, "Vektorisierung" durch Hinzufügen some directives in Ihrem Code "erzwingen".

Wenn Sie von llvm IR starten und nicht vom Quellcode, haben Sie immer noch Befehl line switches for opt

Verwandte Themen