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

[DAGCombine] ICE in combineMinNumMaxNum(...) #60924

Closed
mcinally opened this issue Feb 22, 2023 · 4 comments · Fixed by llvm/llvm-project-release-prs#318
Closed

[DAGCombine] ICE in combineMinNumMaxNum(...) #60924

mcinally opened this issue Feb 22, 2023 · 4 comments · Fixed by llvm/llvm-project-release-prs#318
Assignees
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] llvm:codegen release:backport release:merged

Comments

@mcinally
Copy link
Contributor

mcinally commented Feb 22, 2023

65420c8 introduced an ICE in combineMinNumMaxNum(...) when combineMinNumMaxNumImpl(...) returns an SDValue().

Reproducer is:

$ cat test.ll
define float @test_combinemaxnum(float %sub) #0 {
L.entry:
  %maxnum1 = call float @llvm.maxnum.f32(float 0.000000e+00, float 0.000000e+00)
  br label %L.LB21_850

L.LB21_850:
  %neg1 = fneg fast float %maxnum1
  %neg2 = fneg fast float %sub
  %mask = fcmp fast ule float %maxnum1, %neg2
  %maxnum2 = select i1 %mask, float %neg1, float %sub
  ret float %maxnum2
}

declare dso_local float @llvm.maxnum.f32(float, float)

attributes #0 = { "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" }
$ llc test.ll
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: llc test.ll
1.	Running pass 'Function Pass Manager' on module 'test.ll'.
2.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@test_combinemaxnum'
 #0 0x00005582e44b7088 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (scrubbed/bin/llc+0x1999088)
 #1 0x00005582e44b4ffe llvm::sys::RunSignalHandlers() (scrubbed/bin/llc+0x1996ffe)
 #2 0x00005582e44b781d SignalHandler(int) Signals.cpp:0:0
 #3 0x0000150233b15b20 __restore_rt sigaction.c:0:0
 #4 0x00005582e42f74a8 llvm::SelectionDAG::getNode(unsigned int, llvm::SDLoc const&, llvm::EVT, llvm::SDValue, llvm::SDNodeFlags) (scrubbed/bin/llc+0x17d94a8)
 #5 0x00005582e422970f (anonymous namespace)::DAGCombiner::combineMinNumMaxNum(llvm::SDLoc const&, llvm::EVT, llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::ISD::CondCode) DAGCombiner.cpp:0:0
 #6 0x00005582e41dce5a (anonymous namespace)::DAGCombiner::visitSELECT(llvm::SDNode*) DAGCombiner.cpp:0:0
 #7 0x00005582e41c42bc (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) DAGCombiner.cpp:0:0
 #8 0x00005582e41c10b3 llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOpt::Level) (scrubbed/bin/llc+0x16a30b3)
 #9 0x00005582e4326a7e llvm::SelectionDAGISel::CodeGenAndEmitDAG() (scrubbed/bin/llc+0x1808a7e)
#10 0x00005582e4326407 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (scrubbed/bin/llc+0x1808407)
#11 0x00005582e432416f llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (scrubbed/bin/llc+0x180616f)
#12 0x00005582e34a113f (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) X86ISelDAGToDAG.cpp:0:0
#13 0x00005582e3a840af llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (scrubbed/bin/llc+0xf660af)
#14 0x00005582e3e76aee llvm::FPPassManager::runOnFunction(llvm::Function&) (scrubbed/bin/llc+0x1358aee)
#15 0x00005582e3e7dd83 llvm::FPPassManager::runOnModule(llvm::Module&) (scrubbed/bin/llc+0x135fd83)
#16 0x00005582e3e7770d llvm::legacy::PassManagerImpl::run(llvm::Module&) (scrubbed/bin/llc+0x135970d)
#17 0x00005582e309ebfa main (scrubbed/bin/llc+0x580bfa)
#18 0x0000150232dbc493 __libc_start_main (/lib64/libc.so.6+0x23493)
#19 0x00005582e3099c1e _start (scrubbed/bin/llc+0x57bc1e)
Segmentation fault (core dumped)

There's currently a patch out for review (D144571) to correct this ICE, but filing an issue so that it can be backported to the release/16.x branch.

@mcinally mcinally added this to the LLVM 16.0.0 Release milestone Feb 22, 2023
@mcinally mcinally self-assigned this Feb 22, 2023
@EugeneZelenko EugeneZelenko added backend:X86 crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Feb 22, 2023
@llvmbot
Copy link

llvmbot commented Feb 22, 2023

@llvm/issue-subscribers-backend-x86

mcinally pushed a commit that referenced this issue Feb 22, 2023
65420c8 introduced an ICE in combineMinNumMaxNum(...) when
combineMinNumMaxNumImpl(...) returns an SDValue(). Make sure to check that a
value is returned before trying to perform an FNEG on it.

GitHub Issue: #60924

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D144571
@mcinally
Copy link
Contributor Author

/cherry-pick af4c4f4

@llvmbot
Copy link

llvmbot commented Feb 22, 2023

/branch llvm/llvm-project-release-prs/issue60924

@llvmbot
Copy link

llvmbot commented Feb 22, 2023

/pull-request llvm/llvm-project-release-prs#318

@github-project-automation github-project-automation bot moved this to Needs Triage in LLVM Release Status Feb 24, 2023
@tru tru moved this from Needs Triage to Needs Review in LLVM Release Status Feb 24, 2023
@tru tru moved this from Needs Review to Needs Merge in LLVM Release Status Feb 24, 2023
tru pushed a commit that referenced this issue Feb 24, 2023
65420c8 introduced an ICE in combineMinNumMaxNum(...) when
combineMinNumMaxNumImpl(...) returns an SDValue(). Make sure to check that a
value is returned before trying to perform an FNEG on it.

GitHub Issue: #60924

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D144571

(cherry picked from commit af4c4f4)
@tru tru moved this from Needs Merge to Done in LLVM Release Status Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] llvm:codegen release:backport release:merged
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants