This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Do not select SMULW[BT] or SMLAW[BT]
ClosedPublic

Authored by olista01 on Oct 16 2014, 6:34 AM.

Details

Reviewers
rengolin
Summary

The current instruction selection patterns for SMULW[BT] and SMLAW[BT]
are incorrect. These instructions multiply a 32-bit and a 16-bit value
(both signed) and return the top 32 bits of the 48-bit result. This
preserves the 16 bits of overflow, whereas the patterns they currently
match truncate the result to 16 bits then sign extend.

To select these instructions, we would need to match an ISD::SMUL_LOHI,
a sign extend, two shifts and an or. There is no way to match SMUL_LOHI
in an instruction pattern as it defines multiple values (please correct
me if I am wrong), so this would have to be done in C++. Since this
pattern is not likely to occur often, I will raise a bugzilla ticket for
it.

This fixes http://llvm.org/bugs/show_bug.cgi?id=19396

Diff Detail

Event Timeline

olista01 updated this revision to Diff 15015.Oct 16 2014, 6:34 AM
olista01 retitled this revision from to [ARM] Do not select SMULW[BT] or SMLAW[BT].
olista01 updated this object.
olista01 edited the test plan for this revision. (Show Details)
olista01 set the repository for this revision to rL LLVM.
olista01 added a subscriber: Unknown Object (MLST).

Bugzilla ticket for allowing correct selection of these: http://llvm.org/bugs/show_bug.cgi?id=21297

rengolin accepted this revision.Oct 18 2014, 12:44 PM
rengolin added a reviewer: rengolin.
rengolin added a subscriber: rengolin.

Hi Oliver,

I'm assuming you're going to be working on it in the near future, right? I agree this pattern is unlikely to make any performance regressions for the time being, though.

cheers,
--renato

This revision is now accepted and ready to land.Oct 18 2014, 12:44 PM
olista01 closed this revision.Oct 20 2014, 4:42 AM

Thanks, committed as r220196.

I don't have any immediate plans to work on http://llvm.org/bugs/show_bug.cgi?id=21297, as I don't expect that pattern to appear often in real C code.