Continuation of D69116
Contributes to a Fix for https://bugs.llvm.org/show_bug.cgi?id=43559
Should be commited after D69099 and D69116
Using the TLI hook in DAGCombine.cpp.
Differential D69120
[TargetLowering][DAGCombine][MSP430] Shift Amount Threshold in DAGCombine (2/2) joanlluch on Oct 17 2019, 10:35 AM. Authored by
Details Continuation of D69116 Contributes to a Fix for https://bugs.llvm.org/show_bug.cgi?id=43559 Should be commited after D69099 and D69116 Using the TLI hook in DAGCombine.cpp.
Diff Detail
Event Timeline
Comment Actions Updated tests to reflect each covered case in an independent way with more focused IR patterns.
Comment Actions I created a new baseline revision, D69609, that help to better reflect the effects of applying this patch. The referred revision should therefore be applied before this one for consistency reasons. Comment Actions @spatel I updated this revision diff according to your suggestions. I also created a new baseline test revision to help identify the effects of this patch. I hope this is ok. Thanks in advance for your time. Comment Actions @asl I identified you as the creator of the MSP430 patch that optimised 8 bit and larger shifts by combining them with bswap and extend instructions. This creates relatively cheap instruction sequences for exactly 8 bit shifts. I am considering replacing my current implementation of getShiftAmountThreshold, by a version that passes the intended shift amount as a parameter and returns a boolean. For example, let's say that we have bool shouldAvoidTransformToShift(EVT VT, unsigned amount) const override; Which would return false by default. For the MSP430 it could be implemented like this bool MSP430TargetLowering::shouldAvoidTransformToShift(EVT VT, unsigned amount) const { return !(amount == 8 || amount<=2); } Would this make sense for the MSP430? Thanks. Comment Actions @joanlluch Yes, having the version with amount does make sense as target may know how to efficiently lower some of the shifts with crazy tricks. And in the view of this patch it's easier to preserve the sequences rather than match and undo later. I guess for MSP430 we'd need to allow 9 as possible "special" shift value, as select is lowered to 3 instructions (test + branch + mov of some kind) and removing branch overall has some additional value like allowing more code folding / reducing register pressure. Comment Actions @asl Ok thanks, I agree that 9 bit shifts may also benefit from the version with amount. Comment Actions LGTM
|
Do we have test coverage for each code diff?
It would be good to add a code comment for each test that describes the transform that we are trying to avoid.
For example, this one could copy the formula from the corresponding source code comment: