[llvm-bugs] [Bug 36359] New: Failure to vectorize simple loop to AVX vpaddb

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Feb 12 13:41:22 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=36359

            Bug ID: 36359
           Summary: Failure to vectorize simple loop to AVX vpaddb
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: timshen91 at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 19851
  --> https://bugs.llvm.org/attachment.cgi?id=19851&action=edit
IR file

opt doesn't produce a single instruction for the attached test case:

$ opt -O2 -S a.ll

define <32 x i8> @_Z3AddDv32_cS_(<32 x i8> %a, <32 x i8> %b) local_unnamed_addr
#0 {
entry:
  br label %for.body

for.cond.cleanup:                                 ; preds = %for.body
  ret <32 x i8> %vecins.3

for.body:                                         ; preds = %for.body, %entry
  %i.09 = phi i32 [ 0, %entry ], [ %inc.3, %for.body ]
  %ret.08 = phi <32 x i8> [ undef, %entry ], [ %vecins.3, %for.body ]
  %vecext = extractelement <32 x i8> %a, i32 %i.09
  %vecext1 = extractelement <32 x i8> %b, i32 %i.09
  %add = add i8 %vecext, %vecext1
  %vecins = insertelement <32 x i8> %ret.08, i8 %add, i32 %i.09
  %inc = or i32 %i.09, 1
  %vecext.1 = extractelement <32 x i8> %a, i32 %inc
  %vecext1.1 = extractelement <32 x i8> %b, i32 %inc
  %add.1 = add i8 %vecext.1, %vecext1.1
  %vecins.1 = insertelement <32 x i8> %vecins, i8 %add.1, i32 %inc
  %inc.1 = or i32 %i.09, 2
  %vecext.2 = extractelement <32 x i8> %a, i32 %inc.1
  %vecext1.2 = extractelement <32 x i8> %b, i32 %inc.1
  %add.2 = add i8 %vecext.2, %vecext1.2
  %vecins.2 = insertelement <32 x i8> %vecins.1, i8 %add.2, i32 %inc.1
  %inc.2 = or i32 %i.09, 3
  %vecext.3 = extractelement <32 x i8> %a, i32 %inc.2
  %vecext1.3 = extractelement <32 x i8> %b, i32 %inc.2
  %add.3 = add i8 %vecext.3, %vecext1.3
  %vecins.3 = insertelement <32 x i8> %vecins.2, i8 %add.3, i32 %inc.2
  %inc.3 = add nuw nsw i32 %i.09, 4
  %exitcond.3 = icmp eq i32 %inc.3, 32
  br i1 %exitcond.3, label %for.cond.cleanup, label %for.body
}



However, running opt twice produces the optimized result:
$ ~/build/opt -O2 -S < a.ll | ~/build/opt -S -O2

define <32 x i8> @_Z3AddDv32_cS_(<32 x i8> %a, <32 x i8> %b) local_unnamed_addr
#0 {
entry:
  %0 = add <32 x i8> %a, %b
  ret <32 x i8> %0
}

I suspect that SLPVectorizer didn't pick up some code patterns that are
optimized away in later runs.

-- 
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/20180212/bdd3dcdc/attachment.html>


More information about the llvm-bugs mailing list