https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119971
Bug ID: 119971 Summary: RISC-V: Wrong code with bitmanip extension Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: kristerw at gcc dot gnu.org Target Milestone: --- Compiling with -O3 -march=rv64gcb causes the function foo below to be miscompiled: __attribute__ ((noipa)) unsigned foo (unsigned b, unsigned e, unsigned i) { e >>= b; i >>= e & 31; return i & 1; } int main() { if (foo (0x18, 0xfe000000, 0x40000000) != 1) __builtin_abort (); return 0; } The generated assembly fails to take the masking & 31 into account: foo: srlw a1,a1,a0 bext a0,a2,a1 ret