This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Fix result type for SMULO/UMULO legalization
ClosedPublic

Authored by pftbest on Nov 27 2016, 4:23 PM.

Details

Summary

On some platforms (like MSP430) the second element of the result
structure for SMULO/UMULO may have a shorter type than the one
returned by SetCC. We need to truncate it to the right type, or
else some incorrect code may be generated later on.

This fixes issue https://github.com/rust-lang/rust/issues/37829

Diff Detail

Repository
rL LLVM

Event Timeline

pftbest updated this revision to Diff 79363.Nov 27 2016, 4:23 PM
pftbest retitled this revision from to [CodeGen] Fix result type for SMULO/UMULO legalization.
pftbest updated this object.
pftbest added a reviewer: asl.
pftbest added a subscriber: llvm-commits.
pftbest updated this revision to Diff 79413.Nov 28 2016, 9:10 AM

Check if types are different before truncate

efriedma added inline comments.
lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
3521 ↗(On Diff #79413)

Isn't OType just TopHalf.getType()?

3523 ↗(On Diff #79413)

Please add an assertion that RType.getSizeInBits() <= OType.getSizeInBits(), just in case someone runs into it.

pftbest updated this revision to Diff 79448.Nov 28 2016, 1:37 PM

Added an assertion, and also getting the size in bits from TopHalf directly

efriedma accepted this revision.Nov 30 2016, 10:43 AM
efriedma added a reviewer: efriedma.

LGTM.

This revision is now accepted and ready to land.Nov 30 2016, 10:43 AM

I don't have access to svn, so please commit it for me.

This revision was automatically updated to reflect the committed changes.