[llvm] [AMDGPU] Implement IR expansion for frem instruction (PR #130988)

Frederik Harwath via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 4 06:11:13 PDT 2025


frederik-h wrote:

> > Hi @frederik-h
> > The following starts crashing with this patch:
> > ```
> > llc -mtriple x86_64-unknown-linux-gnu bbi-110248.ll
> > ```
> > 
> > 
> >     
> >       
> >     
> > 
> >       
> >     
> > 
> >     
> >   
> > It fails like
> > ```
> > llc: ../lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp:5858: SDValue llvm::DAGTypeLegalizer::ExpandIntOp_XINT_TO_FP(SDNode *): Assertion `LC != RTLIB::UNKNOWN_LIBCALL && "Don't know how to expand this XINT_TO_FP!"' 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-all/bin/llc -mtriple x86_64-unknown-linux-gnu bbi-110248.ll
> > 1.	Running pass 'Function Pass Manager' on module 'bbi-110248.ll'.
> > 2.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@main'
> >  #0 0x0000556515aa33a6 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (build-all/bin/llc+0x7bd33a6)
> >  #1 0x0000556515aa0af5 llvm::sys::RunSignalHandlers() (build-all/bin/llc+0x7bd0af5)
> >  #2 0x0000556515aa41b9 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
> >  #3 0x00007f42a15a4990 __restore_rt (/lib64/libpthread.so.0+0x12990)
> >  #4 0x00007f429ef4452f raise (/lib64/libc.so.6+0x4e52f)
> >  #5 0x00007f429ef17e65 abort (/lib64/libc.so.6+0x21e65)
> >  #6 0x00007f429ef17d39 _nl_load_domain.cold.0 (/lib64/libc.so.6+0x21d39)
> >  #7 0x00007f429ef3ce86 (/lib64/libc.so.6+0x46e86)
> >  #8 0x00005565158c03f5 llvm::DAGTypeLegalizer::ExpandIntOp_XINT_TO_FP(llvm::SDNode*) LegalizeIntegerTypes.cpp:0:0
> >  #9 0x00005565158bf15f llvm::DAGTypeLegalizer::ExpandIntegerOperand(llvm::SDNode*, unsigned int) LegalizeIntegerTypes.cpp:0:0
> > #10 0x0000556515884c8d llvm::DAGTypeLegalizer::run() LegalizeTypes.cpp:0:0
> > #11 0x000055651588a449 llvm::SelectionDAG::LegalizeTypes() (build-all/bin/llc+0x79ba449)
> > #12 0x0000556515870350 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (build-all/bin/llc+0x79a0350)
> > #13 0x000055651586ed9e llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (build-all/bin/llc+0x799ed9e)
> > #14 0x000055651586c371 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (build-all/bin/llc+0x799c371)
> > #15 0x0000556515869d39 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (build-all/bin/llc+0x7999d39)
> > #16 0x0000556514ab5ee7 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (build-all/bin/llc+0x6be5ee7)
> > #17 0x000055651500ee4c llvm::FPPassManager::runOnFunction(llvm::Function&) (build-all/bin/llc+0x713ee4c)
> > #18 0x00005565150170f2 llvm::FPPassManager::runOnModule(llvm::Module&) (build-all/bin/llc+0x71470f2)
> > #19 0x000055651500f918 llvm::legacy::PassManagerImpl::run(llvm::Module&) (build-all/bin/llc+0x713f918)
> > #20 0x00005565129cef87 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
> > #21 0x00005565129cc500 main (build-all/bin/llc+0x4afc500)
> > #22 0x00007f429ef307e5 __libc_start_main (/lib64/libc.so.6+0x3a7e5)
> > #23 0x00005565129cb96e _start (build-all/bin/llc+0x4afb96e)
> > Abort (core dumped)
> > ```
> > 
> > 
> >     
> >       
> >     
> > 
> >       
> >     
> > 
> >     
> >   
> > I don't know what x86 thinks about i224 as input arguments but this didn't crash before. We see this all over the place in downstream fuzzy testing. [bbi-110248.ll.gz](https://github.com/user-attachments/files/22136413/bbi-110248.ll.gz)
> 
> When running "expand-fp" it just says
> 
> ```
> Skipping pass 'Expand fp' on function main
> ```
> 
> with this patch, but before it expanded it to a lot of stuff.

That's probably related to the things @bjope mentioned. Looking into it right now.

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


More information about the llvm-commits mailing list