Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Assertion failed for sapphirerapids: `VT.getSizeInBits() == Operand.getValueSizeInBits() && "Cannot BITCAST between types of different sizes!"'. #51528

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR52561
Status CONFIRMED
Importance P enhancement
Reported by Vsevolod Livinskiy (Vsevolod.Livinskij@frtk.ru)
Reported on 2021-11-19 11:48:38 -0800
Last modified on 2021-11-19 19:01:00 -0800
Version trunk
Hardware PC Linux
CC babokin@gmail.com, craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, pengfei.wang@intel.com, regehr@cs.utah.edu, spatel+llvm@rotateright.com, Vsevolod.Livinskij@frtk.ru
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Link to the Compiler Explorer: https://godbolt.org/z/qEK4jWTcT

LLVM IR Reproducer:
@b = external local_unnamed_addr global i8, align 1
@d = external local_unnamed_addr global i32, align 4
@c = external local_unnamed_addr global [0 x [8 x i16]], align 2

define void @_Z1ev(i32 %0, i1 %1) local_unnamed_addr #0 {
entry:
  %conv2 = and i32 %0, 65535
  %sub = sub nsw i32 2, %conv2
  br label %omp.inner.for.cond

omp.inner.for.cond:                               ; preds = %cond.end, %entry
  %.omp.iv.0 = phi i32 [ %add19, %cond.end ], [ 0, %entry ]
  %cmp8 = icmp slt i32 %.omp.iv.0, %sub
  br i1 %cmp8, label %omp.inner.for.body, label %simd.if.end.loopexit

omp.inner.for.body:                               ; preds = %omp.inner.for.cond
  %add10 = add i32 %.omp.iv.0, %0
  %2 = and i32 %add10, 65535
  %idxprom = zext i32 %2 to i64
  br i1 %1, label %cond.end, label %cond.true

cond.true:                                        ; preds = %omp.inner.for.body
  %arrayidx13 = getelementptr inbounds [0 x [8 x i16]], [0 x [8 x i16]]* @c, i64 0, i64 1, i64 %idxprom
  %3 = load i16, i16* %arrayidx13, align 2
  %conv14 = trunc i16 %3 to i8
  br label %cond.end

cond.end:                                         ; preds = %cond.true,
%omp.inner.for.body
  %cond = phi i8 [ %conv14, %cond.true ], [ 0, %omp.inner.for.body ]
  store i8 %cond, i8* @b, align 1
  %arrayidx17 = getelementptr inbounds [0 x [8 x i16]], [0 x [8 x i16]]* @c, i64 0, i64 3, i64 %idxprom
  %4 = load i16, i16* %arrayidx17, align 2
  %conv18 = sext i16 %4 to i32
  store i32 %conv18, i32* @d, align 4
  %add19 = add nuw nsw i32 %.omp.iv.0, 1
  br label %omp.inner.for.cond, !llvm.loop !0

simd.if.end.loopexit:                             ; preds = %omp.inner.for.cond
  ret void
}

attributes #0 = { "min-legal-vector-width"="0" }

!0 = distinct !{!0, !1, !3}
!1 = !{!"llvm.loop.parallel_accesses", !2}
!2 = distinct !{}
!3 = !{!"llvm.loop.vectorize.enable", i1 true}

Error:
>$ clang++ -c -O2 -march=sapphirerapids reduced.ll
clang++:
/testing/llvm/llvm_src_main/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:5074:
llvm::SDValue llvm::SelectionDAG::getNode(unsigned int, const llvm::SDLoc&,
llvm::EVT, llvm::SDValue, llvm::SDNodeFlags): Assertion `VT.getSizeInBits() ==
Operand.getValueSizeInBits() && "Cannot BITCAST between types of different
sizes!"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.  Program arguments: clang++ -c -O2 -march=sapphirerapids reduced.ll
1.  Code generation
2.  Running pass 'Function Pass Manager' on module 'reduced.ll'.
3.  Running pass 'X86 DAG->DAG Instruction Selection' on function '@_Z1ev'
 #0 0x0000556a6053f115 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x0000556a6053cd64 llvm::sys::CleanupOnSignal(unsigned long) (/testing/llvm/bin_main/bin/clang-14+0x222bd64)
 #2 0x0000556a60488fc8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007fbb84023520 (/lib/x86_64-linux-gnu/libc.so.6+0x46520)
 #4 0x00007fbb84077808 pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9a808)
 #5 0x00007fbb84023476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x46476)
 #6 0x00007fbb840097b7 abort (/lib/x86_64-linux-gnu/libc.so.6+0x2c7b7)
 #7 0x00007fbb840096db (/lib/x86_64-linux-gnu/libc.so.6+0x2c6db)
 #8 0x00007fbb8401ae26 (/lib/x86_64-linux-gnu/libc.so.6+0x3de26)
 #9 0x0000556a6156c22b llvm::SelectionDAG::getNode(unsigned int, llvm::SDLoc const&, llvm::EVT, llvm::SDValue, llvm::SDNodeFlags) (/testing/llvm/bin_main/bin/clang-14+0x325b22b)
#10 0x0000556a6156d341 llvm::SelectionDAG::getBitcast(llvm::EVT, llvm::SDValue)
(/testing/llvm/bin_main/bin/clang-14+0x325c341)
#11 0x0000556a5f185cb0 combineX86ShuffleChain(llvm::ArrayRef<llvm::SDValue>,
llvm::SDValue, llvm::ArrayRef<int>, int, bool, bool, bool, llvm::SelectionDAG&,
llvm::X86Subtarget const&) X86ISelLowering.cpp:0:0
#12 0x0000556a5f1e28d9
combineX86ShufflesRecursively(llvm::ArrayRef<llvm::SDValue>, int,
llvm::SDValue, llvm::ArrayRef<int>, llvm::ArrayRef<llvm::SDNode const*>,
unsigned int, unsigned int, bool, bool, bool, llvm::SelectionDAG&,
llvm::X86Subtarget const&) X86ISelLowering.cpp:0:0
#13 0x0000556a5f1e1a86
combineX86ShufflesRecursively(llvm::ArrayRef<llvm::SDValue>, int,
llvm::SDValue, llvm::ArrayRef<int>, llvm::ArrayRef<llvm::SDNode const*>,
unsigned int, unsigned int, bool, bool, bool, llvm::SelectionDAG&,
llvm::X86Subtarget const&) X86ISelLowering.cpp:0:0
#14 0x0000556a5f1e1a86
combineX86ShufflesRecursively(llvm::ArrayRef<llvm::SDValue>, int,
llvm::SDValue, llvm::ArrayRef<int>, llvm::ArrayRef<llvm::SDNode const*>,
unsigned int, unsigned int, bool, bool, bool, llvm::SelectionDAG&,
llvm::X86Subtarget const&) X86ISelLowering.cpp:0:0
#15 0x0000556a5f1ef071 combineX86ShufflesRecursively(llvm::SDValue,
llvm::SelectionDAG&, llvm::X86Subtarget const&) (.constprop.0)
X86ISelLowering.cpp:0:0
#16 0x0000556a5f1f1565 combineShuffle(llvm::SDNode*, llvm::SelectionDAG&,
llvm::TargetLowering::DAGCombinerInfo&, llvm::X86Subtarget const&)
X86ISelLowering.cpp:0:0
#17 0x0000556a5f20cb15
llvm::X86TargetLowering::PerformDAGCombine(llvm::SDNode*,
llvm::TargetLowering::DAGCombinerInfo&) const (/testing/llvm/bin_main/bin/clang-
14+0xefbb15)
#18 0x0000556a6148ed55 (anonymous
namespace)::DAGCombiner::combine(llvm::SDNode*) DAGCombiner.cpp:0:0
#19 0x0000556a614907f9 llvm::SelectionDAG::Combine(llvm::CombineLevel,
llvm::AAResults*, llvm::CodeGenOpt::Level) (/testing/llvm/bin_main/bin/clang-
14+0x317f7f9)
#20 0x0000556a615a15f0 llvm::SelectionDAGISel::CodeGenAndEmitDAG()
(/testing/llvm/bin_main/bin/clang-14+0x32905f0)
#21 0x0000556a615a50ef
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&)
(/testing/llvm/bin_main/bin/clang-14+0x32940ef)
#22 0x0000556a615a6fb1
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0)
SelectionDAGISel.cpp:0:0
#23 0x0000556a5f0ac910 (anonymous
namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&)
X86ISelDAGToDAG.cpp:0:0
#24 0x0000556a5f74c758
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(/testing/llvm/bin_main/bin/clang-14+0x143b758)
#25 0x0000556a5fcc9593 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/testing/llvm/bin_main/bin/clang-14+0x19b8593)
#26 0x0000556a5fcc97c9 llvm::FPPassManager::runOnModule(llvm::Module&)
(/testing/llvm/bin_main/bin/clang-14+0x19b87c9)
#27 0x0000556a5fcca0e5 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/testing/llvm/bin_main/bin/clang-14+0x19b90e5)
#28 0x0000556a608808b3 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef,
llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/testing/llvm/bin_main/bin/clang-14+0x256f8b3)
#29 0x0000556a616e5c38 clang::CodeGenAction::ExecuteAction()
(/testing/llvm/bin_main/bin/clang-14+0x33d4c38)
#30 0x0000556a60f8c389 clang::FrontendAction::Execute()
(/testing/llvm/bin_main/bin/clang-14+0x2c7b389)
#31 0x0000556a60f194de
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/testing/llvm/bin_main/bin/clang-14+0x2c084de)
#32 0x0000556a61054ed8
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/testing/llvm/bin_main/bin/clang-14+0x2d43ed8)
#33 0x0000556a5efad181 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/testing/llvm/bin_main/bin/clang-14+0xc9c181)
#34 0x0000556a5efa8de4 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#35 0x0000556a60da3699 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#36 0x0000556a6048915c
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/testing/llvm/bin_main/bin/clang-14+0x217815c)
#37 0x0000556a60da3fbc
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const (.part.0) Job.cpp:0:0
#38 0x0000556a60d75952
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const (/testing/llvm/bin_main/bin/clang-
14+0x2a64952)
#39 0x0000556a60d764f9
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
(/testing/llvm/bin_main/bin/clang-14+0x2a654f9)
#40 0x0000556a60d841a9
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/testing/llvm/bin_main/bin/clang-14+0x2a731a9)
#41 0x0000556a5ef27401 main (/testing/llvm/bin_main/bin/clang-14+0xc16401)
#42 0x00007fbb8400afd0 (/lib/x86_64-linux-gnu/libc.so.6+0x2dfd0)
#43 0x00007fbb8400b07d __libc_start_main (/lib/x86_64-linux-
gnu/libc.so.6+0x2e07d)
#44 0x0000556a5efa8765 _start (/testing/llvm/bin_main/bin/clang-14+0xc97765)
clang-14: error: clang frontend command failed with exit code 134 (use -v to
see invocation)
clang version 14.0.0 (https://github.com/llvm/llvm-project.git
8fb3f84484094230d563c1e4c1088755b7cde15b)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /testing/llvm/bin_main/bin

C++ Reproducer:
char a, b;
extern short c[][8];
int d;
void e() {
#pragma omp simd
  for (unsigned short f(a); f < 2; f += (unsigned short)268435455 - 65534) {
    b = c[2][f] ? c[1][f] : 0;
    d = c[3][f];
  }
}

Error:
>$ clang++ -c -O2 -fopenmp-simd -march=sapphirerapids func.cpp
Quuxplusone commented 3 years ago

Thanks for reporting it. Candidate patch: https://reviews.llvm.org/D114304