https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120553
Bug ID: 120553 Summary: Improve code to select between -1 and various values Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: law at gcc dot gnu.org Target Milestone: --- I recently added code to improve our ability to generate -1, 1 based on the sign bit of an input value. ie x < 0 ? -1 : 1. That can be generalized to generate -1, 2^n for n = 0..63 when the zbs extension is allowed. Instead of using ori to set the low bit, use bset to set whatever bit we want like these two example for long foo1 (long c) { return c >= 0 ? 0x4000 : -1; } srai a0, a0, 63 bseti a0, a0, 14