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: unassignedb...@nondot.org
          Reporter: timshe...@gmail.com
                CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to