<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - SLP vectorizer fails to vectorize obvious candidates"
   href="http://llvm.org/bugs/show_bug.cgi?id=22555">22555</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>SLP vectorizer fails to vectorize obvious candidates
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>chandlerc@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider my test case:

% cat wtf_slp.ll                                   
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define void @test(i64* %in, i64* %out) {
  %in.0 = getelementptr i64* %in, i32 0
  %in.1 = getelementptr i64* %in, i32 1
  %a = load i64* %in.0, align 16
  %b = load i64* %in.1, align 8
  %a.and = and i64 %a, -2
  %b.and = and i64 %b, -2
  %out.0 = getelementptr i64* %out, i32 0
  %out.1 = getelementptr i64* %out, i32 1
  store i64 %a.and, i64* %out.0, align 16
  store i64 %b.and, i64* %out.1, align 8
  ret void
}

The loads and stores are perfectly aligned. The operations are trivial to do in
the vector unit. I would love this to get vectorized. It doesn't:


% ./bin/opt -S -mcpu=corei7 -o - -slp-vectorizer wtf_slp.ll -debug
Args: ./bin/opt -S -mcpu=corei7 -o - -slp-vectorizer wtf_slp.ll -debug 

Features:+64bit,+sse2
CPU:corei7

Subtarget features: SSELevel 7, 3DNowLevel 0, 64bit 1

Features:+64bit,+sse2
CPU:corei7

Subtarget features: SSELevel 7, 3DNowLevel 0, 64bit 1
SLP: Analyzing blocks in test.
SLP: Found 2 stores to vectorize.
SLP: Analyzing a store chain of length 2.
SLP: Analyzing a store chain of length 2
SLP: Analyzing 2 stores at offset 0
SLP:  bundle:   store i64 %a.and, i64* %out.0, align 16
SLP:  initialize schedule region to   store i64 %a.and, i64* %out.0, align 16
SLP:  extend schedule region end to   store i64 %b.and, i64* %out.1, align 8
SLP: try schedule bundle [  store i64 %a.and, i64* %out.0, align 16;  store i64
%b.and, i64* %out.1, align 8] in block 
SLP:       update deps of [  store i64 %a.and, i64* %out.0, align 16;  store
i64 %b.and, i64* %out.1, align 8]
SLP:       update deps of /   store i64 %b.and, i64* %out.1, align 8
SLP: We are not able to schedule this bundle!
SLP:  cancel scheduling of [  store i64 %a.and, i64* %out.0, align 16;  store
i64 %b.and, i64* %out.1, align 8]
SLP: Calculating cost for tree of size 1.
SLP: Check whether the tree with height 1 is fully vectorizable .
SLP: Found cost=2147483647 for VF=2
; ModuleID = 'wtf_slp.ll'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define void @test(i64* %in, i64* %out) {
  %in.0 = getelementptr i64* %in, i32 0
  %in.1 = getelementptr i64* %in, i32 1
  %a = load i64* %in.0, align 16
  %b = load i64* %in.1, align 8
  %a.and = and i64 %a, -2
  %b.and = and i64 %b, -2
  %out.0 = getelementptr i64* %out, i32 0
  %out.1 = getelementptr i64* %out, i32 1
  store i64 %a.and, i64* %out.0, align 16
  store i64 %b.and, i64* %out.1, align 8
  ret void
}


Being unable to vectorize obvious code not only is likely hurting performance
and generated code size, it also makes the SLP vectorizer impossible to write
good test cases for when fixing bugs.

We really, really need this optimization pass to work in expected and obvious
ways. Right now, it appears to only handle very specific (and surprising)
patterns reliably.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>