mem_signed_long.c (680B)
1 /* mem: a signed 32-bit value stored to / reloaded from a volatile stack slot 2 * (stur w/ldur w) then sign-extended into a 64-bit chain, with a negative 3 * magnitude large enough that a wrong (zero-extending) widening would change 4 * the result. Distinct from mem_signed in that the value is consumed as a long 5 * throughout (sxtw / 64-bit arithmetic). Exit: 42. */ 6 int test_main(void) { 7 volatile int neg = -1000000; /* 0xFFF0BDC0 as bits */ 8 long widened = neg; /* ldrsw: must stay negative */ 9 long doubled = widened + widened; /* -2000000 */ 10 long back = doubled / -1000000; /* 2 ; no signed overflow */ 11 return (int)(back * 21); /* 42 */ 12 }