https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117688
Bug ID: 117688
Summary: RISC-V: Wrong code for .SAT_SUB
Product: gcc
Version: 15.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: ---
The following test fails when compiled as
riscv64-unknown-linux-gnu-gcc -O2 -march=rv64gc bug.c
#include <stdint.h>
int8_t x, y, result;
__attribute__ ((noipa)) void
foo ()
{
int8_t minus;
_Bool overflow = __builtin_sub_overflow (x, y, &minus);
result = overflow ? (x < 0 ? 0x80 : 0x7f) : minus;
}
int main ()
{
x = 0x80;
y = 0x78;
foo();
if (result != (int8_t)0x80)
__builtin_abort ();
return 0;
}