Closed
Description
Minimal C reproducer(s):
int a(int x) { return x*x; }
long b(int x) { return x*x; }
Expected output (on riscv64, generated with -fwrapv
):
a: # @a
mulw a0, a0, a0
ret
What is actually generated:
a: # @a
mulw a0, a0, a0
slli a0, a0, 32
srli a0, a0, 32
ret
compiler explorer link: https://godbolt.org/z/Yq898xoT1. Clang 14 produces the optimal code for a
but not for b
.