Skip to content

[LoopInterchange] Creates invalid IR: PHINode should have one entry for each predecessor of its parent basic block! #149730

@sjoerdmeijer

Description

@sjoerdmeijer

See also: https://godbolt.org/z/xaKeMP6zh

This input:

bool a;
short b;
void fn1(bool c, short d[][2][2]) {
  for (char e = 0; e < (char)b; e++)
    for (char f(c); f < 020; f += 2)
      a = d[f][f][f] ?: d[e][f][e] - d[e][f + 2][e];
}

compiled with: -std=c++11 -Ofast -floop-interchange -mcpu=grace

Results in this crash:

 #0 0x0000000003c90a38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c90a38)
 #1 0x0000000003c8e40c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c8e40c)
 #2 0x0000000003bde738 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007bd8f5e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x000000000589fc68 llvm::VPlanTransforms::buildPlainCFG(llvm::Loop*, llvm::LoopInfo&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x589fc68)
 #5 0x000000000574ceaa llvm::LoopVectorizationPlanner::buildVPlansWithVPRecipes(llvm::ElementCount, llvm::ElementCount) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x574ceaa)
 #6 0x000000000574d6a3 llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x574d6a3)

I haven't created an IR reproducer yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashPrefer [crash-on-valid] or [crash-on-invalid]vectorizers

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions