This is an archive of the discontinued LLVM Phabricator instance.

[X86] In decomposeMulByConstant, legalize the VT before querying whether the multiply is legal
ClosedPublic

Authored by craig.topper on Jul 31 2019, 1:11 PM.

Details

Summary

If a type is larger than a legal type and needs to be split, we would previously allow the multiply to be decomposed even if the split multiply is legal. Since the shift + add/sub code would also need to be split, its not any better to decompose it.

This patch figures out what type the mul will eventually be legalized to and then uses that type for the query. I tried just returning false illegal types and letting them get handled after type legalization, but then we can't recognize and i64 constant splat on 32-bit targets since will be destroyed by type legalization. We could special case vectors of i64 to avoid that...

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Jul 31 2019, 1:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 31 2019, 1:11 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
spatel accepted this revision.Aug 1 2019, 3:40 AM

LGTM

llvm/lib/Target/X86/X86ISelLowering.cpp
4891–4892 ↗(On Diff #212646)

This comment should include the reasoning from the patch description. It won't be obvious when scanning the code in the future why we chose this logic over a simpler legality check.

4893 ↗(On Diff #212646)

Don't need the temp variable if the original VT is never used again?

This revision is now accepted and ready to land.Aug 1 2019, 3:40 AM
This revision was automatically updated to reflect the committed changes.