This is an archive of the discontinued LLVM Phabricator instance.

[LoongArch] Combine ((x & shifted_mask) >> shamt) to bstrpick.{w/d}
ClosedPublic

Authored by SixWeining on Jun 20 2022, 5:54 AM.

Details

Summary

This is an improvement to LoongArch codegen. In D127206 we combined
((x >> shamt) & shifted_mask) to bstrpick and here we do a similar
combination when certain conditions are met.

Thanks to @xen0n for reminding me.

Diff Detail

Event Timeline

SixWeining created this revision.Jun 20 2022, 5:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 20 2022, 5:54 AM
SixWeining requested review of this revision.Jun 20 2022, 5:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 20 2022, 5:54 AM
xen0n added a comment.Jun 20 2022, 6:27 AM

Nice overall improvements, thanks!

Only one minor suggestion. Do you think an extra test case that verifies something like (x & 0xfff0) >> 17 are properly optimized to 0? Or is such an optimization already covered by all the generic mechanisms so it's not needed here?

Nice overall improvements, thanks!

Only one minor suggestion. Do you think an extra test case that verifies something like (x & 0xfff0) >> 17 are properly optimized to 0? Or is such an optimization already covered by all the generic mechanisms so it's not needed here?

Yes, I have meant to write such a negative test but I find it have already been optimized to 0. So I think we don’t need it here.

xen0n accepted this revision.Jun 20 2022, 6:56 AM

LGTM, thanks!

This revision is now accepted and ready to land.Jun 20 2022, 6:56 AM
xen0n added a comment.Jun 20 2022, 6:58 AM

Nice overall improvements, thanks!

Only one minor suggestion. Do you think an extra test case that verifies something like (x & 0xfff0) >> 17 are properly optimized to 0? Or is such an optimization already covered by all the generic mechanisms so it's not needed here?

Yes, I have meant to write such a negative test but I find it have already been optimized to 0. So I think we don’t need it here.

I guessed so. So this is fine, and I've approved. We may wait for a couple of days for others to take a look at this though.

This revision was landed with ongoing or failed builds.Jun 23 2022, 2:20 AM
This revision was automatically updated to reflect the committed changes.