What decides whether an optimiser's proposed change is valid?
Which tasks belong to the compiler back end?
Two local integer sums may swap if they are independent, cannot overflow or trap, and have no observable effects.
Circle one: True False
In the exact-integer model, 9 + 3 has no side effects or traps. Why may the compiler replace it with 12?
LOAD R,[x] loads x into R; MUL R,S and ADD R,S overwrite R with R*S and R+S. To compute a*b+c, run LOAD R1,[a]; LOAD R2,[b]; MUL R1,R2. b is no longer needed. Which continuation leaves a*b+c in R1 without spilling?
A platform requires a device read that clears a set event flag. Its returned value is unused. Why must the optimiser retain it?
Single-threaded code sets local t = a+b, then logs fixed text. Neither statement can fail or transfer control; the sum cannot overflow and has no effects. The log does not use t. No shared-state or timing observation is allowed. May they swap?
value starts at 0. The program computes value = 4*3, then writes value to a device. An optimiser swaps these statements without changing either. Is that valid?