This is an archive of the discontinued LLVM Phabricator instance.

[Power9]Legalize and emit code for converting (Un)Signed DWord to Quad-Precision
ClosedPublic

Authored by lei on Apr 3 2018, 2:33 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

lei created this revision.Apr 3 2018, 2:33 PM
lei added a reviewer: nemanjai.Apr 3 2018, 4:54 PM
lei removed a subscriber: nemanjai.
nemanjai requested changes to this revision.Apr 4 2018, 5:38 AM

I think overall, we want to cover all the ways we can get the input integer:

  • Extending load from a smaller type (only unsigned forms for byte and halfword, both signed and unsigned for word)
  • Extracting from a vector (with sign extensions as needed)
  • Smaller types in registers
  • An fp to int conversion
  • A bitcast

I don't mind that being split up into multiple patches, but I think we can at least start with a test case for each of the cases with FIXME's for what we're going to cover in upcoming patches.

lib/Target/PowerPC/PPCInstrVSX.td
3121 ↗(On Diff #140863)

I just realized that we should also add patterns for converting an extracted vector value to f128 because it will currently do mfvsrd -> mtvsrd -> xscv[us]dqp which is obviously redundant.
We will also need patterns for extending loads from byte, halfword and word.

test/CodeGen/PowerPC/f128-conv.ll
3 ↗(On Diff #140863)

Please add test cases that convert from smaller integer types as well (byte, halfword and word).

22 ↗(On Diff #140863)

Please also add a version of the test where the integer value is passed as a parameter by pointer (for both the signed and unsigned conversions).

This revision now requires changes to proceed.Apr 4 2018, 5:38 AM
lei added inline comments.Apr 5 2018, 12:10 PM
lib/Target/PowerPC/PPCInstrVSX.td
3121 ↗(On Diff #140863)

Will post patterns for extending these in a separate patch.

test/CodeGen/PowerPC/f128-conv.ll
3 ↗(On Diff #140863)

will be done in a separate patch

22 ↗(On Diff #140863)

okay

lei updated this revision to Diff 141196.Apr 5 2018, 12:40 PM

Additional test cases added: [u|s]dwConv2qp_03()

lei marked an inline comment as done.Apr 5 2018, 12:40 PM
lei updated this revision to Diff 141834.Apr 10 2018, 6:42 AM

Only legalize (un)signed int to FP conv if converting to f128

lei updated this revision to Diff 141866.Apr 10 2018, 9:08 AM
nemanjai accepted this revision.Apr 12 2018, 5:16 AM

LGTM. Feel free to address the nit comments on the commit.

lib/Target/PowerPC/PPCISelLowering.cpp
9413 ↗(On Diff #141866)

Nit: complete sentences - don't forget the punctuation. Also, no need to be this generic here. Something like // Conversions to f128 are legal. should communicate this more clearly.

test/CodeGen/PowerPC/f128-conv.ll
17 ↗(On Diff #141866)

This isn't guaranteed to use the same register for input/output. Perhaps something like:
; CHECK: xscvsdqp [[CONV:[0-9]+]], [[REG]]
would be more appropriate (and of course, use CONV below).
This applies to all the tests below.

102 ↗(On Diff #141866)

Please add a test case that will actually use the X-Form load. Perhaps something like:

void testXForm(__float128 *sink, signed char *a) {
  *sink = *((long long *) (a + 3));
}
This revision is now accepted and ready to land.Apr 12 2018, 5:16 AM
This revision was automatically updated to reflect the committed changes.