Saves materializing the immediate for the "ands".
Corresponding patterns exist for lsrs+lsls, but that seems less common in practice.
Now implemented as a DAGCombine.
Differential D49585
[ARM] Prefer lsls+lsrs over lsls+ands or lsrs+ands in Thumb1. efriedma on Jul 19 2018, 7:37 PM. Authored by
Details Saves materializing the immediate for the "ands". Corresponding patterns exist for lsrs+lsls, but that seems less common in practice. Now implemented as a DAGCombine.
Diff Detail
Event TimelineComment Actions Nice optimisation, looks good to me. About where this should go, I am also not so sure. Looks like this is not so different from what's already done in Select, but I would propably first have thought about a Combine, and am not sure if it matters. Perhaps @samparker has an opinion on this.
Comment Actions I did some work for Thumb-2 last year in a similar vain during the combine phase, in PerformSHLSimplify, but this (unsurprisingly) doesn't handle lshr. I didn't find any headaches from changing the canonical form in those cases, so probably would be worth having it there. Comment Actions Changed to DAGCombine, added some more tests for related patterns, added some FIXMEs for future improvements.
Comment Actions Note that DAGCombine already does such a transform, but not in the case of constants (D48768) Comment Actions I don't think this makes sense for other targets... other targets generally have an and-with-immediate instruction, and in that case this transform saves zero instructions. Or do you have some specific target in mind? Comment Actions I don't have any specific target in mind, but this is pretty generic, thus i suggested it. |