Skip to content

Legalize Types - Crash in soften float UINT_TO_FP result. #3039

@bcardosolopes

Description

@bcardosolopes
Bugzilla Link 2667
Resolution FIXED
Resolved on Nov 10, 2008 11:39
Version trunk
OS Linux
Attachments bytecode from newlib lcong48.c
CC @bcardosolopes,@efriedma-quic

Extended Description

The problem occurs when we have, for example a i16,ch = load... followed by an f64 = uint_to_fp...

$ mips-llc lib_a-erand48.bc -f -enable-legalize-types -debug
Promote integer result: 0xf54748: i16,ch = load 0xf52a48, 0xf52448, 0xf52b48 <0xf39510:0> alignment=2
Soften float result 0: 0xf54848: f64 = uint_to_fp 0xf54748
mips-llc: /p/llvm/svn/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp:290: llvm::SDValue llvm::DAGTypeLegalizer::SoftenFloatRes_UINT_TO_FP(llvm::SDNode*): Assertion `LC != RTLIB::UNKNOWN_LIBCALL && "Unsupported UINT_TO_FP!"' failed.

The problem here, is that in method DAGTypeLegalizer::SoftenFloatRes_UINT_TO_FP,
the helper RTLIB::getUINTTOFP doesn't know how to soften i16 -> f64. This happens because the i16 load result is promoted, but it only replaces the chain Uses, not the i16 ones, and since the uint_to_fp result is legalized before its operands, we get this crash.

All targets with native support for f64 doesnt crash, since they dont legalize the result, but only the operand.

One quick hack is to replace the unsupported types (in this case i16) Uses with the new promoted type in PromoteIntRes_LOAD, but this break PromoteOp for other test cases, and IMHO, considering the LegalizeTypes design, it doesnt seems like the right approach.

It's worth mentioning that this bug doesn't exist when legalize types is disabled.

I volunteer to fix this, I would just appreciate some opinions.
Thanks,

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions