[Bug target/123010] RV64: 32-bit multiply by 2 generates slli+srai+slli and doesn't use slliw or addw

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Dec 4 19:13:42 GMT 2025


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123010

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to camel-cdr from comment #4)
> I don't really see how this would be a parameter/return value thing,
> considering the multiply by 3 does use addw.

Also try:
```
#include <stdint.h>

#define N 2

void mulu(uint32_t *a) {
    *a = *a * N;
}

void muls(int32_t *a) {
    *a = *a * N;
}

```

You will GCC produces:
```
        lw      a5,0(a0)
        slliw   a5,a5,1
        sw      a5,0(a0)
        ret
```


More information about the Gcc-bugs mailing list