mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-27 04:18:42 +00:00
LegalizeDAG: make sure cast is unsigned before using FP_TO_UINT.
It's valid to use FP_TO_SINT when asking for a smaller type (e.g. all "unsigned int16" values fit into a "signed int32"), but the reverse isn't true. Unfortunately, I'm not actually aware of any architecture with asymmetric FP_TO_SINT and FP_TO_UINT handling and the logic happens to work in the symmetric case, so I can't actually write a test for this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210986 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
1 parent
8bfc50e4a9
commit
40ed1d89b1
1 file changed
+4
-1
@@ -2650,12 +2650,15 @@ SDValue SelectionDAGLegalize::PromoteLegalFP_TO_INT(SDValue LegalOp,
|
||||
NewOutTy = (MVT::SimpleValueType)(NewOutTy.getSimpleVT().SimpleTy+1);
|
||||
assert(NewOutTy.isInteger() && "Ran out of possibilities!");
|
||||
|
||||
// A larger signed type can hold all unsigned values of the requested type,
|
||||
// so using FP_TO_SINT is valid
|
||||
if (TLI.isOperationLegalOrCustom(ISD::FP_TO_SINT, NewOutTy)) {
|
||||
OpToUse = ISD::FP_TO_SINT;
|
||||
break;
|
||||
}
|
||||
|
||||
if (TLI.isOperationLegalOrCustom(ISD::FP_TO_UINT, NewOutTy)) {
|
||||
// However, if the value may be < 0.0, we *must* use some FP_TO_SINT.
|
||||
if (!isSigned && TLI.isOperationLegalOrCustom(ISD::FP_TO_UINT, NewOutTy)) {
|
||||
OpToUse = ISD::FP_TO_UINT;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user