<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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] "PHI nodes not grouped at top of basic block!" after "SLP Vectorizer" after r338380"
   href="https://bugs.llvm.org/show_bug.cgi?id=38418">38418</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[SLP] "PHI nodes not grouped at top of basic block!" after "SLP Vectorizer" after r338380
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>ilia.taraban@intel.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This test crashes after "SLP Vectorizer" after r338380 :

================= nice.cpp ============
struct b2Vec2
{
    b2Vec2 (float x, float y) : x(x), y(y)
    {
    }
    void operator -= (const b2Vec2 & v)
    {
        x -= v.x;
        y -= v.y;
    }
    float x, y;
};
struct b2Vec3
{
    b2Vec3 (int x, int y, int z) : x(0), y(0), z(0)
    {
    }
    float x, y, z;
};
struct b2Mat33
{
    b2Vec3 Solve33 (const b2Vec3 & b) const;
    b2Vec2 Solve22 (const b2Vec2 & b) const;
};
inline float b2Cross (const b2Vec2 & a, const b2Vec2 & b)
{
    return a.x - a.y * b.x;
}
inline b2Vec2 operator * (int s, const b2Vec2 & a)
{
    return b2Vec2(s * a.x, s * a.y);
}

struct b2Velocity;
class b2RevoluteJoint
{
    void SolveVelocityConstraints (b2Velocity * velocities);
    b2Vec3 m_impulse;
    bool m_enableLimit;
    int m_indexA;
    b2Vec2 m_rA;
    b2Vec2 m_rB;
    int m_invMassA;
    int m_invIA;
    int m_invIB;
    b2Mat33 m_mass;
};
struct b2Velocity
{
    b2Vec2 v;
    int w;
};

void b2RevoluteJoint:: SolveVelocityConstraints (b2Velocity * velocities)
{
    b2Vec2 vA = velocities->v;
    int wA = 0;
    b2Vec2 vB = velocities->v;
    int wB = 0;
    int mA = m_invMassA;
    float iA = m_invIA, iB = m_invIB;
    if (m_enableLimit) 
    {
        b2Vec2 Cdot1 = vB;
        b2Vec3 Cdot (0, 0, 0);
        b2Vec3 impulse = m_mass.Solve33(Cdot);
        int newImpulse = m_impulse.z;
        if (newImpulse) 
        {
            b2Vec2 rhs = Cdot1;
            b2Vec2 reduced = m_mass.Solve22(rhs);
            impulse.x = reduced.x;
            impulse.z = m_impulse.z;
        } else 
        {
        }
        b2Vec2 P (impulse.x, impulse.y);
        vA -= mA * P;
        wA -= iA * (b2Cross(m_rA, P) + impulse.z);
        wB += iB * (b2Cross(m_rB, P));
    } else 
    {
        b2Vec2 Cdot = vB;
        b2Vec2 impulse = m_mass.Solve22(Cdot);
        vA -= impulse;
        wA -= iA * b2Cross(m_rA, impulse);
        wB += iB * b2Cross(m_rB, impulse);
    }
    velocities->v = vA;
    velocities[m_indexA].w = wA;
    velocities->w = wB;
}

=======================================


<span class="quote">>>> clang -v</span >
clang version 8.0.0 (trunk  338677)
Target: x86_64-unknown-linux-gnu
Thread model: posix
...


<span class="quote">>>> clang++ -c  -O2 -ffast-math nice.cpp</span >
PHI nodes not grouped at top of basic block!
  %impulse.sroa.6.0 = phi float [ %11, %if.then6 ], [ %call.fca.1.extract,
%if.then ]
label %if.end
fatal error: error in backend: Broken function found, compilation aborted!
clang-8: error: clang frontend command failed with exit code 70 (use -v to see
invocation)
clang version 8.0.0 (trunk 338677)
Target: x86_64-unknown-linux-gnu
Thread model: posix

IR reproducer:
================= fine.ll =============
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: uwtable
define dso_local void @foo() local_unnamed_addr  align 2 {
  br i1 false, label %16, label %1

; <label>:1:                                      ; preds = %0
  br i1 undef, label %3, label %2

; <label>:2:                                      ; preds = %1
  br label %3

; <label>:3:                                      ; preds = %2, %1
  %4 = phi <2 x float> [ undef, %2 ], [ undef, %1 ]
  %5 = phi float [ undef, %2 ], [ undef, %1 ]
  %6 = extractelement <2 x float> %4, i32 0
  %7 = extractelement <2 x float> %4, i32 1
  %8 = fmul fast float %6, undef
  %9 = fmul fast float %7, undef
  %10 = fsub fast float undef, %8
  %11 = fsub fast float undef, %9
  %12 = fmul fast float undef, %6
  %13 = fsub fast float undef, %12
  %14 = fmul fast float undef, %6
  %15 = fsub fast float undef, %14
  br label %17

; <label>:16:                                     ; preds = %0
  br label %17

; <label>:17:                                     ; preds = %16, %3
  %18 = phi float [ undef, %16 ], [ %10, %3 ]
  %19 = phi float [ undef, %16 ], [ %11, %3 ]
  %20 = phi float [ undef, %16 ], [ %15, %3 ]
  %21 = phi float [ undef, %16 ], [ %13, %3 ]
  ret void
}
=======================================

<span class="quote">>>> opt fine.ll -verify</span >

<span class="quote">>>> opt fine.ll -slp-vectorizer -o fine.opt.ll</span >
PHI nodes not grouped at top of basic block!
  %5 = phi float [ undef, %2 ], [ undef, %1 ]
label %3
LLVM ERROR: Broken function found, compilation aborted!

This test started failing after :
------------------------------------------------------------------------
r338380 | abataev | 2018-07-31 16:02:43 +0200 (Tue, 31 Jul 2018) | 13 lines

[SLP] Fix PR38339: Instruction does not dominate all uses!

Summary:
If the ExtractElement instructions can be optimized out during the
vectorization and we need to reshuffle the parent vector, this
ShuffleInstruction may be inserted in the wrong place causing compiler
to produce incorrect code.

Reviewers: spatel, RKSimon, mkuper, hfinkel, javed.absar

Subscribers: llvm-commits

Differential Revision: <a href="https://reviews.llvm.org/D49928">https://reviews.llvm.org/D49928</a>
------------------------------------------------------------------------</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>