[llvm-bugs] [Bug 38418] New: [SLP] "PHI nodes not grouped at top of basic block!" after "SLP Vectorizer" after r338380

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 2 03:28:38 PDT 2018


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

            Bug ID: 38418
           Summary: [SLP] "PHI nodes not grouped at top of basic block!"
                    after "SLP Vectorizer" after r338380
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: ilia.taraban at intel.com
                CC: llvm-bugs at lists.llvm.org

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;
}

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


>>> clang -v
clang version 8.0.0 (trunk  338677)
Target: x86_64-unknown-linux-gnu
Thread model: posix
...


>>> clang++ -c  -O2 -ffast-math nice.cpp
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
}
=======================================

>>> opt fine.ll -verify

>>> opt fine.ll -slp-vectorizer -o fine.opt.ll
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: https://reviews.llvm.org/D49928
------------------------------------------------------------------------

-- 
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/20180802/85b97d3c/attachment.html>


More information about the llvm-bugs mailing list