This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Unify handling for conversion of FP_TO_INT feeding a store
ClosedPublic

Authored by lei on Apr 25 2018, 8:14 PM.

Details

Summary

Existing DAG combine only handles conversions for:

`{ FP_TO_SINT (f32, f64) } x { i32, i16 }

This patch simplifies the code to handle:

`{ FP_TO_SINT, FP_TO_UINT } x { f64, f32 } x { i64, i32, i16, i8 }`

Diff Detail

Event Timeline

lei created this revision.Apr 25 2018, 8:14 PM
nemanjai requested changes to this revision.May 7 2018, 5:31 AM

The code changes required are minor, but there's a few so I'd prefer to see another review of this patch.

lib/Target/PowerPC/PPCISelLowering.cpp
1161

Hmm... turns out the names are pretty long. Please drop the CV_ prefix from both.

1218

This one is pretty long too. Maybe ST_VSR_SCAL_INT?

12235

Nit: formatting. The parameters should be aligned.

12258

Floating point types smaller than 32 bits are not legal on Power. I think you should just exit early if the type has a width less than 32 bits and only extend if if has a width of 32 bits (since that extend is free).
Especially since you don't have a test case for this code path.

lib/Target/PowerPC/PPCInstrVSX.td
1470

This introduces ambiguity for the selector and it may result in unpredictable results from ISEL. The reason is that this pattern has the exact same complexity and code size as the pair in the HasP9Vector block. What you should do is guard the STXSDX patterns with the additional NoP9Vector predicate.

3173–3200

Add to this comment that the 8-byte version is repeated here due to the availability of D-Form STXSD.

This revision now requires changes to proceed.May 7 2018, 5:31 AM
lei added inline comments.May 7 2018, 6:35 AM
lib/Target/PowerPC/PPCInstrVSX.td
1470

But the pattern in the HasP9Vector bloc is for xaddr while this one is for xoaddr. Does that not differentiate the two patterns?

nemanjai added inline comments.May 7 2018, 7:01 AM
lib/Target/PowerPC/PPCInstrVSX.td
1470

That isn't adequate because xoaddr cannot fail and fall back on ixaddr. So if the selector tries to match the pattern that has the xoaddr, it will succeed every time making it impossible to select the D-Form version.

lei updated this revision to Diff 145469.May 7 2018, 8:38 AM
lei marked 6 inline comments as done.

Addressed all review comments.

nemanjai accepted this revision.May 7 2018, 7:31 PM

Thanks for addressing everything so quickly. LGTM.

lib/Target/PowerPC/PPCISelLowering.cpp
12277

Nit: Spaces around infix operators.

This revision is now accepted and ready to land.May 7 2018, 7:31 PM
This revision was automatically updated to reflect the committed changes.