[llvm] [VectorCombine] Add Cmp and Select for shuffleToIdentity (PR #92794)

Stephen Tozer via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 28 08:13:17 PDT 2024


SLTozer wrote:

This looks to cause an assertion with the following reproducer:
```
$ cat repro.ll
define void @foo(ptr %this) {
entry:
  %0 = load <2 x float>, ptr inttoptr (i64 -60 to ptr), align 4
  %1 = load <2 x float>, ptr inttoptr (i64 -72 to ptr), align 4
  %2 = extractelement <2 x float> %0, i64 0
  %cmp.i903 = fcmp ogt float %2, 0.000000e+00
  %sel1639 = select i1 %cmp.i903, <2 x float> %0, <2 x float> %1
  %3 = fcmp ogt <2 x float> %0, zeroinitializer
  %sel48.i913 = select <2 x i1> %3, <2 x float> %0, <2 x float> %1
  %4 = shufflevector <2 x float> %sel1639, <2 x float> %sel48.i913, <2 x i32> <i32 0, i32 3>
  %5 = call <2 x float> @llvm.maxnum.v2f32(<2 x float> %4, <2 x float> zeroinitializer)
  %6 = getelementptr i8, ptr %this, i64 1424
  %7 = extractelement <2 x float> %5, i64 0
  store float %7, ptr %6, align 16
  ret void
}
$ ./build/bin/opt -passes=vector-combine repro.ll -S
opt: /home/gbtozers/dev/upstream-llvm/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From *) [To = llvm::FixedVectorType, From = llvm::Type]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: ./build/bin/opt -passes=vector-combine repro.ll -S
 #0 0x0000557d91364278 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./build/bin/opt+0x3ee2278)
 #1 0x0000557d913622a0 llvm::sys::RunSignalHandlers() (./build/bin/opt+0x3ee02a0)
 #2 0x0000557d91364c18 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f756af8a520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f756afde9fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007f756afde9fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007f756afde9fc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007f756af8a476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007f756af707f3 abort ./stdlib/abort.c:81:7
 #9 0x00007f756af7071b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007f756af81e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x0000557d927a119f (anonymous namespace)::VectorCombine::run()::$_0::operator()(llvm::Instruction&) const VectorCombine.cpp:0:0
#12 0x0000557d927980d1 llvm::VectorCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (./build/bin/opt+0x53160d1)
#13 0x0000557d924d4cfd llvm::detail::PassModel<llvm::Function, llvm::VectorCombinePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilderPipelines.cpp:0:0
#14 0x0000557d9152fd5b llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (./build/bin/opt+0x40add5b)
#15 0x0000557d924d688d llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilderPipelines.cpp:0:0
#16 0x0000557d9153479e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (./build/bin/opt+0x40b279e)
#17 0x0000557d924cfd7d llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) PassBuilderPipelines.cpp:0:0
#18 0x0000557d9152eaab llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (./build/bin/opt+0x40acaab)
#19 0x0000557d92475fcc llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (./build/bin/opt+0x4ff3fcc)
#20 0x0000557d9132d12b optMain (./build/bin/opt+0x3eab12b)
#21 0x00007f756af71d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#22 0x00007f756af71e40 call_init ./csu/../csu/libc-start.c:128:20
#23 0x00007f756af71e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#24 0x0000557d9132afe5 _start (./build/bin/opt+0x3ea8fe5)
Aborted
```

https://github.com/llvm/llvm-project/pull/92794


More information about the llvm-commits mailing list