Skip to content

PHI nodes not grouped at top of BB after vector-combine pass #60649

Closed
@ashermancinelli

Description

@ashermancinelli

After the vector-combine pass, a PHI node is added after other instructions in the basic block.

opt -passes=vector-combine test.ll -print-before-all -print-after-all -print-module-scope -S

Test case:

*** IR Dump Before VectorCombinePass on foo ***
; ModuleID = 't.ll'
source_filename = "t.ll"
target datalayout = "e-p:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

define linkonce_odr void @foo() personality ptr null {
L.B5956:
  br label %L.B0779

L.B0778.preheader:                                ; No predecessors!
  br label %L.B0779

L.B0779:                                          ; preds = %L.B0778.preheader, %L.B5956
  %0 = phi <4 x double> [ zeroinitializer, %L.B5956 ], [ zeroinitializer, %L.B0778.preheader ]
  %1 = phi <4 x double> [ zeroinitializer, %L.B5956 ], [ zeroinitializer, %L.B0778.preheader ]
  %2 = shufflevector <4 x double> zeroinitializer, <4 x double> zeroinitializer, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
  %3 = fdiv <4 x double> %0, %2
  %4 = fmul <4 x double> %0, %2
  %5 = shufflevector <4 x double> %3, <4 x double> %4, <4 x i32> <i32 0, i32 1, i32 6, i32 7>
  store <4 x double> %5, ptr null, align 8
  ret void
}

Bad IR:

*** IR Dump After VectorCombinePass on foo ***
; ModuleID = 't.ll'
source_filename = "t.ll"
target datalayout = "e-p:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

define linkonce_odr void @foo() personality ptr null {
L.B5956:
  br label %L.B0779

L.B0778.preheader:                                ; No predecessors!
  br label %L.B0779

L.B0779:                                          ; preds = %L.B0778.preheader, %L.B5956
  %0 = phi <4 x double> [ zeroinitializer, %L.B5956 ], [ zeroinitializer, %L.B0778.preheader ]
  %1 = shufflevector <4 x double> %0, <4 x double> %0, <4 x i32> <i32 2, i32 3, i32 undef, i32 undef>
  %2 = shufflevector <4 x double> %0, <4 x double> %0, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>

  %3 = phi <4 x double> [ zeroinitializer, %L.B5956 ], [ zeroinitializer, %L.B0778.preheader ]
  Here ^^^^^

  %4 = fdiv <4 x double> %2, <double 0.000000e+00, double 0.000000e+00, double undef, double undef>
  %5 = fmul <4 x double> %1, <double 0.000000e+00, double 0.000000e+00, double undef, double undef>
  %6 = shufflevector <4 x double> %4, <4 x double> %5, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
  store <4 x double> %6, ptr null, align 8
  ret void
}

Stack trace:

PHI nodes not grouped at top of basic block!
  %3 = phi <4 x double> [ zeroinitializer, %L.B5956 ], [ zeroinitializer, %L.B0778.preheader ]
label %L.B0779
LLVM ERROR: Broken module found, compilation aborted!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
Program arguments: opt -passes=vector-combine -print-after-all -print-module-scope -print-before-all t.ll -S
 #0 0x0000561239dec528 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (llvm-install/bin/opt+0x1af9528)
 #1 0x0000561239dea49e llvm::sys::RunSignalHandlers() (llvm-install/bin/opt+0x1af749e)
 #2 0x0000561239deccbd SignalHandler(int) Signals.cpp:0:0
 #3 0x00007fc5bbe90c20 __restore_rt sigaction.c:0:0
 #4 0x00007fc5bb14b37f raise (/lib64/libc.so.6+0x3737f)
 #5 0x00007fc5bb135db5 abort (/lib64/libc.so.6+0x21db5)
 #6 0x0000561239d7c3ec llvm::report_fatal_error(llvm::Twine const&, bool) (llvm-install/bin/opt+0x1a893ec)
 #7 0x0000561239d7c216 (llvm-install/bin/opt+0x1a89216)
 #8 0x0000561239824a0c (llvm-install/bin/opt+0x1531a0c)
 #9 0x0000561238920ced llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (llvm-install/bin/opt+0x62dced)
#10 0x00005612397fc977 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (llvm-install/bin/opt+0x1509977)
#11 0x0000561238919256 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool) (llvm-install/bin/opt+0x626256)
#12 0x0000561238926fd3 main (llvm-install/bin/opt+0x633fd3)
#13 0x00007fc5bb137493 __libc_start_main (/lib64/libc.so.6+0x23493)
#14 0x0000561238912a3e _start (llvm-install/bin/opt+0x61fa3e)

CC @mcinally

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions