https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67869
Bug ID: 67869 Summary: [SH] Expand some dynamic shifts inline Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: olegendo at gcc dot gnu.org Target Milestone: --- Target: sh*-*-* On SH variants without dynamic shift instructions like shld and shad dynamic shifts are done via a libcall. For some cases the shift range is known to be limited, for example: unsigned int test_0 (unsigned int x, unsigned int y) { // valid value for y is 0,1,2,3 // otherwise it's undefined behavior return x >> (y * 8); } unsigned int test_1 (unsigned int x, unsigned int y) { // value of y i known to be 0,1,2,3 return x << (y & 3); } In such cases a sequence like: shlr r4 bf .Lx0 shll8 r5 .Lx0: shlr r4 bf .L0x shll16 r5 .L0x: can be expanded inline which is better than the libcall.