[LLVMbugs] [Bug 20234] New: [SLP] SLP cost model changes when operands are commuted.
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Jul 7 15:06:23 PDT 2014
http://llvm.org/bugs/show_bug.cgi?id=20234
Bug ID: 20234
Summary: [SLP] SLP cost model changes when operands are
commuted.
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Loop Optimizer
Assignee: unassignedbugs at nondot.org
Reporter: mcrosier at codeaurora.org
CC: aschwaighofer at apple.com, chandlerc at gmail.com,
hfinkel at anl.gov, llvmbugs at cs.uiuc.edu,
nrotem at apple.com
Classification: Unclassified
While modifying the reassociation pass I noticed the ordering of operands
changes the result computed by the SLP cost model.
Specifically, if the operands of
%add = fadd fast float %mul11, %mul12
are commuted
%add = fadd fast float %mul12, %mul11
then the straight line code is not vectorized. See below.
------------------------------------------------------------------------------
$> more test.ll
target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
target triple = "aarch64--linux-gnu"
%structA = type { [2 x float] }
define void @good(%structA* nocapture readonly %J, i32 %xmin, i32 %ymin) {
entry:
br label %for.body3.lr.ph
for.body3.lr.ph:
%conv5 = sitofp i32 %ymin to float
%conv = sitofp i32 %xmin to float
%arrayidx4 = getelementptr inbounds %structA* %J, i64 0, i32 0, i64 0
%0 = load float* %arrayidx4, align 4
%sub = fsub fast float %conv, %0
%arrayidx9 = getelementptr inbounds %structA* %J, i64 0, i32 0, i64 1
%1 = load float* %arrayidx9, align 4
%sub10 = fsub fast float %conv5, %1
%mul11 = fmul fast float %sub, %sub
%mul12 = fmul fast float %sub10, %sub10
%add = fadd fast float %mul11, %mul12
%cmp = fcmp oeq float %add, 0.000000e+00
br i1 %cmp, label %for.body3.lr.ph, label %for.end27
for.end27:
ret void
}
define void @bad(%structA* nocapture readonly %J, i32 %xmin, i32 %ymin) {
entry:
br label %for.body3.lr.ph
for.body3.lr.ph:
%conv5 = sitofp i32 %ymin to float
%conv = sitofp i32 %xmin to float
%arrayidx4 = getelementptr inbounds %structA* %J, i64 0, i32 0, i64 0
%0 = load float* %arrayidx4, align 4
%sub = fsub fast float %conv, %0
%arrayidx9 = getelementptr inbounds %structA* %J, i64 0, i32 0, i64 1
%1 = load float* %arrayidx9, align 4
%sub10 = fsub fast float %conv5, %1
%mul11 = fmul fast float %sub, %sub
%mul12 = fmul fast float %sub10, %sub10
%add = fadd fast float %mul12, %mul11 ;;;<---- Operands commuted!!
%cmp = fcmp oeq float %add, 0.000000e+00
br i1 %cmp, label %for.body3.lr.ph, label %for.end27
for.end27:
ret void
}
------------------------------------------------------------------------------
$> opt -slp-vectorizer test.ll -S
; ModuleID = '/prj/llvm-arm/home/mrosier/15096/test.ll'
target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
target triple = "aarch64--linux-gnu"
%structA = type { [2 x float] }
define void @good(%structA* nocapture readonly %J, i32 %xmin, i32 %ymin) {
entry:
%0 = insertelement <2 x i32> undef, i32 %xmin, i32 0
%1 = insertelement <2 x i32> %0, i32 %ymin, i32 1
br label %for.body3.lr.ph
for.body3.lr.ph: ; preds = %for.body3.lr.ph,
%entry
%2 = sitofp <2 x i32> %1 to <2 x float>
%arrayidx4 = getelementptr inbounds %structA* %J, i64 0, i32 0, i64 0
%arrayidx9 = getelementptr inbounds %structA* %J, i64 0, i32 0, i64 1
%3 = bitcast float* %arrayidx4 to <2 x float>*
%4 = load <2 x float>* %3, align 4
%5 = fsub <2 x float> %2, %4
%6 = fmul <2 x float> %5, %5
%7 = extractelement <2 x float> %6, i32 0
%8 = extractelement <2 x float> %6, i32 1
%add = fadd fast float %7, %8
%cmp = fcmp oeq float %add, 0.000000e+00
br i1 %cmp, label %for.body3.lr.ph, label %for.end27
for.end27: ; preds = %for.body3.lr.ph
ret void
}
define void @bad(%structA* nocapture readonly %J, i32 %xmin, i32 %ymin) {
entry:
br label %for.body3.lr.ph
for.body3.lr.ph: ; preds = %for.body3.lr.ph,
%entry
%conv5 = sitofp i32 %ymin to float
%conv = sitofp i32 %xmin to float
%arrayidx4 = getelementptr inbounds %structA* %J, i64 0, i32 0, i64 0
%0 = load float* %arrayidx4, align 4
%sub = fsub fast float %conv, %0
%arrayidx9 = getelementptr inbounds %structA* %J, i64 0, i32 0, i64 1
%1 = load float* %arrayidx9, align 4
%sub10 = fsub fast float %conv5, %1
%mul11 = fmul fast float %sub, %sub
%mul12 = fmul fast float %sub10, %sub10
%add = fadd fast float %mul12, %mul11
%cmp = fcmp oeq float %add, 0.000000e+00
br i1 %cmp, label %for.body3.lr.ph, label %for.end27
for.end27: ; preds = %for.body3.lr.ph
ret void
}
------------------------------------------------------------------------------
I know nothing about the cost model, but I imagine commuting the operands
shouldn't have such an effect.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140707/7ac9d542/attachment.html>
More information about the llvm-bugs
mailing list