Page MenuHomePhabricator

GlobalISel: Implement lower for S64->S32 [SU]ITOFP
ClosedPublic

Authored by arsenm on May 16 2019, 11:47 AM.

Details

Summary

This is ported from the custom AMDGPU DAG implementation. I think this
is a better default expansion than what the DAG currently uses, at
least if the target has CTLZ.

This implements the signed version in terms of the unsigned
conversion, which is implemented with bit operations. SelectionDAG has
several other implementations that should eventually be ported
depending on what instructions are legal.

Diff Detail

Event Timeline

arsenm created this revision.May 16 2019, 11:47 AM

There is a second expansion in LegalizeDAG which involves temporary stack slots

To clarify, LegalizeDAG combined with TargetLowering have the following lowerings:

  1. UINT_TO_FP i64->f32, in TargetLowering::expandUINT_TO_FP.
  2. UINT_TO_FP i64->f64, in TargetLowering::expandUINT_TO_FP.
  3. SINT_TO_FP from i32->any float, using f64 as an intermediate type, in SelectionDAGLegalize::ExpandLegalINT_TO_FP
  4. UINT_TO_FP from i32->any float, using f64 as an intermediate type, in SelectionDAGLegalize::ExpandLegalINT_TO_FP
  5. UINT_TO_FP on top of an SINT_TO_FP with the same source/destination types, in SelectionDAGLegalize::ExpandLegalINT_TO_FP. (It's not obvious to me that this lowering actually rounds correctly, but I can't figure out how to trigger it, anyway.)
  6. Promoting the integer operand of an XINT_TO_FP to a larger type.
lib/CodeGen/GlobalISel/LegalizerHelper.cpp
2994

Would it make sense to factor this out into a separate function with an appropriate name, so we don't have to modify that function when other lowerings are implemented?

arsenm updated this revision to Diff 200023.May 17 2019, 5:45 AM
arsenm edited the summary of this revision. (Show Details)

Move bulk of implementation to separate function

aemerson accepted this revision.Fri, May 17, 3:47 PM
This revision is now accepted and ready to land.Fri, May 17, 3:47 PM
arsenm closed this revision.Fri, May 17, 4:02 PM

r361081