Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[X86] [ISEL] Assertion hits in PerformDAGCombine/combineMul #111170

Closed
nurmukhametov opened this issue Oct 4, 2024 · 4 comments
Closed

[X86] [ISEL] Assertion hits in PerformDAGCombine/combineMul #111170

nurmukhametov opened this issue Oct 4, 2024 · 4 comments
Assignees
Labels
backend:X86 crash Prefer [crash-on-valid] or [crash-on-invalid] release:backport

Comments

@nurmukhametov
Copy link
Contributor

Consider the following code

target datalayout = "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32-a:0:32-S32"
target triple = "i686-pc-windows-msvc"

define void @f_fu___un_3C_unf_3E_vyi(<16 x i32> %x_load, ptr %offsetsPtr.i) {
allocas:
  %mul__x_load = mul <16 x i32> <i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20>, %x_load
  store <16 x i32> %mul__x_load, ptr %offsetsPtr.i, align 4
  %blend1.i12.i = call <8 x float> @llvm.x86.avx.blendv.ps.256(<8 x float> zeroinitializer, <8 x float> <float 0x36E4000000000000, float 0x36E4000000000000, float 0x36E4000000000000, float 0x36E4000000000000, float 0x36E4000000000000, float 0x36E4000000000000, float 0x36E4000000000000, float 0x36E4000000000000>, <8 x float> zeroinitializer)
  %blend.i13.i = shufflevector <8 x float> zeroinitializer, <8 x float> %blend1.i12.i, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
  %blendAsInt.i14.i = bitcast <16 x float> %blend.i13.i to <16 x i32>
  store <16 x i32> %blendAsInt.i14.i, ptr null, align 4
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare <8 x float> @llvm.x86.avx.blendv.ps.256(<8 x float>, <8 x float>, <8 x float>) #0

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }

that hits Assertion when compiled with the following command

$ llc test.ll -mcpu=corei7-avx -march=x86

llc: /root/llvm-project/llvm/lib/IR/Constants.cpp:1689: llvm::Constant* llvm::Constant::getSplatValue(bool) const: Assertion `this->getType()->isVectorTy() && "Only valid for vectors!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel -mcpu=corei7-avx -march=x86 <source>
1.	Running pass 'Function Pass Manager' on module '<source>'.
2.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@f_fu___un_3C_unf_3E_vyi'
 #0 0x0000000003b5d748 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3b5d748)
 #1 0x0000000003b5b0fc SignalHandler(int) Signals.cpp:0:0
 #2 0x000070dc43242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x000070dc432969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x000070dc43242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x000070dc432287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x000070dc4322871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #7 0x000070dc43239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #8 0x0000000002fd5d3f llvm::Constant::getSplatValue(bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2fd5d3f)
 #9 0x0000000002fd6b63 llvm::Constant::getUniqueInteger() const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2fd6b63)
#10 0x000000000202ac8e combineMul(llvm::SDNode*, llvm::SelectionDAG&, llvm::TargetLowering::DAGCombinerInfo&, llvm::X86Subtarget const&) X86ISelLowering.cpp:0:0
#11 0x00000000020cdf4a llvm::X86TargetLowering::PerformDAGCombine(llvm::SDNode*, llvm::TargetLowering::DAGCombinerInfo&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x20cdf4a)
#12 0x00000000037b0c41 (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) DAGCombiner.cpp:0:0
#13 0x00000000037b24c8 (anonymous namespace)::DAGCombiner::Run(llvm::CombineLevel) DAGCombiner.cpp:0:0
#14 0x00000000037b4dda llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOptLevel) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x37b4dda)
#15 0x00000000039165f4 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x39165f4)
#16 0x0000000003919782 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3919782)
#17 0x000000000391aaa0 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x391aaa0)
#18 0x000000000390b7df llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x390b7df)
#19 0x0000000002aee0a9 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#20 0x00000000030e6070 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x30e6070)
#21 0x00000000030e6421 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x30e6421)
#22 0x00000000030e6cd7 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x30e6cd7)
#23 0x00000000008641fc compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#24 0x00000000007514f6 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x7514f6)
#25 0x000070dc43229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#26 0x000070dc43229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#27 0x000000000085aefe _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x85aefe)
Program terminated with signal: SIGSEGV
Compiler returned: 139

Compiler explorer link: https://godbolt.org/z/KWx9zGd3Y

It looks like it started to crash since 59d14b6

@nurmukhametov
Copy link
Contributor Author

@RKSimon, can you take a look?

@EugeneZelenko EugeneZelenko added backend:X86 crash Prefer [crash-on-valid] or [crash-on-invalid] llvm:SelectionDAG SelectionDAGISel as well and removed new issue labels Oct 4, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 4, 2024

@llvm/issue-subscribers-backend-x86

Author: Aleksei Nurmukhametov (nurmukhametov)

Consider the following code
target datalayout = "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32-a:0:32-S32"
target triple = "i686-pc-windows-msvc"

define void @<!-- -->f_fu___un_3C_unf_3E_vyi(&lt;16 x i32&gt; %x_load, ptr %offsetsPtr.i) {
allocas:
  %mul__x_load = mul &lt;16 x i32&gt; &lt;i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20, i32 20&gt;, %x_load
  store &lt;16 x i32&gt; %mul__x_load, ptr %offsetsPtr.i, align 4
  %blend1.i12.i = call &lt;8 x float&gt; @<!-- -->llvm.x86.avx.blendv.ps.256(&lt;8 x float&gt; zeroinitializer, &lt;8 x float&gt; &lt;float 0x36E4000000000000, float 0x36E4000000000000, float 0x36E4000000000000, float 0x36E4000000000000, float 0x36E4000000000000, float 0x36E4000000000000, float 0x36E4000000000000, float 0x36E4000000000000&gt;, &lt;8 x float&gt; zeroinitializer)
  %blend.i13.i = shufflevector &lt;8 x float&gt; zeroinitializer, &lt;8 x float&gt; %blend1.i12.i, &lt;16 x i32&gt; &lt;i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15&gt;
  %blendAsInt.i14.i = bitcast &lt;16 x float&gt; %blend.i13.i to &lt;16 x i32&gt;
  store &lt;16 x i32&gt; %blendAsInt.i14.i, ptr null, align 4
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare &lt;8 x float&gt; @<!-- -->llvm.x86.avx.blendv.ps.256(&lt;8 x float&gt;, &lt;8 x float&gt;, &lt;8 x float&gt;) #<!-- -->0

attributes #<!-- -->0 = { nocallback nofree nosync nounwind willreturn memory(none) }

that hits Assertion when compiled with the following command

$ llc test.ll -mcpu=corei7-avx -march=x86

llc: /root/llvm-project/llvm/lib/IR/Constants.cpp:1689: llvm::Constant* llvm::Constant::getSplatValue(bool) const: Assertion `this-&gt;getType()-&gt;isVectorTy() &amp;&amp; "Only valid for vectors!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel -mcpu=corei7-avx -march=x86 &lt;source&gt;
1.	Running pass 'Function Pass Manager' on module '&lt;source&gt;'.
2.	Running pass 'X86 DAG-&gt;DAG Instruction Selection' on function '@<!-- -->f_fu___un_3C_unf_3E_vyi'
 #<!-- -->0 0x0000000003b5d748 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3b5d748)
 #<!-- -->1 0x0000000003b5b0fc SignalHandler(int) Signals.cpp:0:0
 #<!-- -->2 0x000070dc43242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #<!-- -->3 0x000070dc432969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #<!-- -->4 0x000070dc43242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #<!-- -->5 0x000070dc432287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #<!-- -->6 0x000070dc4322871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #<!-- -->7 0x000070dc43239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #<!-- -->8 0x0000000002fd5d3f llvm::Constant::getSplatValue(bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2fd5d3f)
 #<!-- -->9 0x0000000002fd6b63 llvm::Constant::getUniqueInteger() const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2fd6b63)
#<!-- -->10 0x000000000202ac8e combineMul(llvm::SDNode*, llvm::SelectionDAG&amp;, llvm::TargetLowering::DAGCombinerInfo&amp;, llvm::X86Subtarget const&amp;) X86ISelLowering.cpp:0:0
#<!-- -->11 0x00000000020cdf4a llvm::X86TargetLowering::PerformDAGCombine(llvm::SDNode*, llvm::TargetLowering::DAGCombinerInfo&amp;) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x20cdf4a)
#<!-- -->12 0x00000000037b0c41 (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) DAGCombiner.cpp:0:0
#<!-- -->13 0x00000000037b24c8 (anonymous namespace)::DAGCombiner::Run(llvm::CombineLevel) DAGCombiner.cpp:0:0
#<!-- -->14 0x00000000037b4dda llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOptLevel) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x37b4dda)
#<!-- -->15 0x00000000039165f4 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x39165f4)
#<!-- -->16 0x0000000003919782 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3919782)
#<!-- -->17 0x000000000391aaa0 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x391aaa0)
#<!-- -->18 0x000000000390b7df llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x390b7df)
#<!-- -->19 0x0000000002aee0a9 llvm::MachineFunctionPass::runOnFunction(llvm::Function&amp;) (.part.0) MachineFunctionPass.cpp:0:0
#<!-- -->20 0x00000000030e6070 llvm::FPPassManager::runOnFunction(llvm::Function&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x30e6070)
#<!-- -->21 0x00000000030e6421 llvm::FPPassManager::runOnModule(llvm::Module&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x30e6421)
#<!-- -->22 0x00000000030e6cd7 llvm::legacy::PassManagerImpl::run(llvm::Module&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x30e6cd7)
#<!-- -->23 0x00000000008641fc compileModule(char**, llvm::LLVMContext&amp;) llc.cpp:0:0
#<!-- -->24 0x00000000007514f6 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x7514f6)
#<!-- -->25 0x000070dc43229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#<!-- -->26 0x000070dc43229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#<!-- -->27 0x000000000085aefe _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x85aefe)
Program terminated with signal: SIGSEGV
Compiler returned: 139

Compiler explorer link: https://godbolt.org/z/KWx9zGd3Y

It looks like it started to crash since 59d14b6

@RKSimon
Copy link
Collaborator

RKSimon commented Oct 5, 2024

/cherry-pick 9459d72

llvmbot pushed a commit to llvmbot/llvm-project that referenced this issue Oct 5, 2024
…nt, ensure we're only accepting ConstantInt splat scalars.

Fixes llvm#111170

(cherry picked from commit 9459d72)
@llvmbot llvmbot closed this as completed Oct 5, 2024
@github-project-automation github-project-automation bot moved this from Needs Triage to Done in LLVM Release Status Oct 5, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 5, 2024

/pull-request #111246

tru pushed a commit to llvmbot/llvm-project that referenced this issue Oct 15, 2024
…nt, ensure we're only accepting ConstantInt splat scalars.

Fixes llvm#111170

(cherry picked from commit 9459d72)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:X86 crash Prefer [crash-on-valid] or [crash-on-invalid] release:backport
Projects
Development

No branches or pull requests

4 participants