[llvm-bugs] [Bug 45823] New: Missing vectorization of loop due to load late in the loop

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 6 23:21:28 PDT 2020


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

            Bug ID: 45823
           Summary: Missing vectorization of loop due to load late in the
                    loop
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: mikael.holmen at ericsson.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 23456
  --> https://bugs.llvm.org/attachment.cgi?id=23456&action=edit
bbi-39227-lv.ll

Reproduce with
 opt -loop-vectorize -S -o - bbi-39227-lv.ll -debug

Result:
 LV: Not vectorizing: Found an unidentified PHI   %h.15 = phi i32 [ %h.11,
%inner.cond.preheader ], [ %h.1, %inner.body ]

The inner loop body looks like:

inner.body:                                       ; preds =
%inner.cond.preheader, %inner.body
  %h.15 = phi i32 [ %h.11, %inner.cond.preheader ], [ %h.1, %inner.body ]
  %h.pn4 = phi i32* [ %h, %inner.cond.preheader ], [ %hp.1, %inner.body ]
  %j.03 = phi i16 [ 0, %inner.cond.preheader ], [ %j.1, %inner.body ]
  %real.02 = phi i32 [ 0, %inner.cond.preheader ], [ %sub, %inner.body ]
  %hp.1 = getelementptr inbounds i32, i32* %h.pn4, i64 1
; The loop can get vectorized if the load is placed here...
  %h.1 = load i32, i32* %hp.1, align 1
  %0 = shl i32 %h.15, 16
  %conv7 = ashr exact i32 %0, 16
  %add = sub i32 %real.02, %h.15
  %sub = add i32 %add, %conv7
  %j.1 = add nuw nsw i16 %j.03, 1
; ... but not when it's here.
;  %h.1 = load i32, i32* %hp.1, align 1
  %cmp3 = icmp ult i16 %j.03, 99
  br i1 %cmp3, label %inner.body, label %inner.end

If we  move the load
   %h.1 = load i32, i32* %hp.1, align 1
earlier in the loop so it's placed directly after the definition of %hp.1, we
instead get:
 LV: We can vectorize this loop!

This PR is the result of the following discussion on llvm-dev:
 https://lists.llvm.org/pipermail/llvm-dev/2020-May/141404.html

-- 
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/20200507/497a8f98/attachment.html>


More information about the llvm-bugs mailing list