#include /* gen_cvt_sxtw test: verify sign-extension from 32-bit int to 64-bit long long. Without the fix, the riscv64 backend had an empty stub for gen_cvt_sxtw, leaving upper 32 bits unmodified (containing whatever was in the register before), so (long long)(int)x produced wrong results for negative values. */ int main(void) { int ok = 1; int x = 0x80000000; long long y = (long long)x; printf("y=%llx\n", (unsigned long long)y); if (y != 0xffffffff80000000LL) { printf("FAIL: int→long long sign-extension\n"); ok = 0; } /* Also test positive value. */ x = 0x40000000; y = (long long)x; printf("y=%llx\n", (unsigned long long)y); if (y != 0x40000000LL) { printf("FAIL: int→long long positive value\n"); ok = 0; } /* Test via unsigned int to catch zero-extension vs sign-extension. */ unsigned int ux = 0x80000000; long long uy = (long long)(int)ux; printf("uy=%llx\n", (unsigned long long)uy); if (uy != 0xffffffff80000000LL) { printf("FAIL: unsigned→int→long long sign-extension\n"); ok = 0; } printf("%s\n", ok ? "PASS" : "FAIL"); return ok ? 0 : 1; }