[llvm-bugs] [Bug 32317] New: Loop vectorizer miscompile resulting in additional loop iteration

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 16 11:01:15 PDT 2017


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

            Bug ID: 32317
           Summary: Loop vectorizer miscompile resulting in additional
                    loop iteration
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: igor at azulsystems.com
                CC: llvm-bugs at lists.llvm.org

Attached test case produces incorrect result when run -force-vector-width=2:

$ lli test.ll
89.000000

$ opt -S -O3 -force-vector-width=2 test.ll > test.opt.ll
$ lli test.opt.ll
90.000000

$ opt -S -O3 -force-vector-width=4 test.ll > test.opt.ll
$ lli test.opt.ll
89.000000

Looking at the output I believe that vectorizer incorrectly calculates
resulting loop value for the fFld:

vector.body:                                      
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <2 x i64> [ <i64 4, i64 5>, %vector.ph ], [ %vec.ind.next,
%vector.body ]
  %vector.recur = phi <2 x i64> [ %vector.recur.init, %vector.ph ], [ %20,
%vector.body ]
  %20 = add nsw <2 x i64> %vec.ind, %broadcast.splat
  %21 = shufflevector <2 x i64> %vector.recur, <2 x i64> %20, <2 x i32> <i32 1,
i32 2>
  %index.next = add i64 %index, 2
  %vec.ind.next = add <2 x i64> %vec.ind, <i64 2, i64 2>
  %22 = icmp eq i64 %index.next, 86
  br i1 %22, label %middle.block, label %vector.body, !llvm.loop !52

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 86, 86
  %vector.recur.extract = extractelement <2 x i64> %20, i32 1
  br i1 %cmp.n, label %bci_64, label %scalar.ph

If in the "%vector.recur.extract" instead of the "%20" we would have used
"%vec.ind" - result would have been correct.

Attached .ll test case and roughly equivalent c code.

-- 
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/20170316/d5737202/attachment.html>


More information about the llvm-bugs mailing list