FreeExam

Compiler engineer: Optimization Correctness

Original technical interview scenarios on SSA, dataflow, memory dependence, arithmetic semantics, speculation, loops, analysis invalidation, and validation. Questions distinguish legality from profitability.

These prompts are original practice. They are not questions from a named employer or a live hiring loop.

  1. 1.An optimization produces faster output but changes a defined program result. What failed?

    Show answer and explanation
    1. IR well-formedness
    2. Semantic preservation
    3. Register-pressure profitability
    4. Source-location fidelity

    Answer: Semantic preservation

    Optimization must preserve the relevant observable behavior.

  2. 2.A rewrite is correct only when x is nonzero. What must justify applying it?

    Show answer and explanation
    1. A valid nonzero proof
    2. A frequent input value
    3. A profile with no observed zero
    4. A favorable cost estimate

    Answer: A valid nonzero proof

    A precondition must hold for every affected defined execution.

  3. 3.An analysis says two pointers may alias. What may the optimizer safely infer?

    Show answer and explanation
    1. Proven disjointness
    2. Possible overlap
    3. Equality of the pointers' loaded values
    4. Interchangeable access semantics

    Answer: Possible overlap

    May-alias is conservative uncertainty, not proof of independence.

  4. 4.A load is moved before a potentially aliasing store. What proof is needed?

    Show answer and explanation
    1. Lower load latency
    2. The source order of the instructions
    3. Equal operand type names
    4. Preserved memory behavior

    Answer: Preserved memory behavior

    Memory dependence can make reordering observable.

  5. 5.An unknown call lies between two loads. What must common-subexpression elimination consider?

    Show answer and explanation
    1. The call's cost
    2. Its argument count without memory-effect information
    3. Possible memory modification
    4. The load's register class

    Answer: Possible memory modification

    A call may invalidate a previously loaded value.

  6. 6.A store is deleted because no local load follows. What else matters?

    Show answer and explanation
    1. Local use count alone
    2. The stored value's frequency in benchmarks
    3. The assignment's source line
    4. Observable memory uses

    Answer: Observable memory uses

    Escaping memory and later callers can observe the store.

  7. 7.A volatile access appears unused. What should deletion consider?

    Show answer and explanation
    1. The result's deadness alone
    2. The access's arithmetic value without observable access rules
    3. Its required observable access semantics
    4. The instruction's cost

    Answer: Its required observable access semantics

    Volatile operations can be observable independently of value use.

  8. 8.Two atomic operations are reordered. What must remain valid?

    Show answer and explanation
    1. Only final local values
    2. The number of instructions in the block
    3. Memory ordering
    4. The chosen register order

    Answer: Memory ordering

    Concurrent semantics can constrain transformations beyond local arithmetic.

  9. 9.A loop-invariant divide may trap on a path where the loop never runs. What can hoisting change?

    Show answer and explanation
    1. Only the divide's result precision
    2. Only the number of loop-body instructions
    3. Trap occurrence
    4. Only spill placement inside the loop

    Answer: Trap occurrence

    Speculating a potentially trapping operation can add behavior.

  10. 10.An expensive pure total expression is loop-invariant, its operands dominate the preheader, and hoisting is proven legal. Why can hoisting still be unprofitable if many executions skip the loop?

    Show answer and explanation
    1. It must violate dominance despite the stated proof.
    2. Every invariant expression changes overflow semantics.
    3. It performs the work on zero-iteration executions.
    4. The loop body cannot contain any invariant values.

    Answer: It performs the work on zero-iteration executions.

    Hoisting can execute the expensive expression even when the loop has zero iterations. Semantic legality does not by itself establish that the changed execution cost is favorable.

  11. 11.A transformation moves a computation to a block not dominated by its definition. What invariant can fail?

    Show answer and explanation
    1. Register affinity
    2. Instruction selection profitability
    3. Symbol visibility
    4. Operand availability

    Answer: Operand availability

    An operand must be available on every path reaching its use.

  12. 12.In SSA, a definition dominates an ordinary use. What does that require?

    Show answer and explanation
    1. The definition is textually earlier somewhere.
    2. All relevant paths cross the definition.
    3. The definition has more uses than other values.
    4. The containing blocks have equal sizes.

    Answer: All relevant paths cross the definition.

    Dominance is a control-flow path property.

  13. 13.A join receives values from two predecessor edges. What does a phi select by?

    Show answer and explanation
    1. The larger numeric operand
    2. The first listed value on every execution
    3. The earliest source declaration
    4. The incoming control-flow edge

    Answer: The incoming control-flow edge

    Phi semantics are associated with the predecessor that transfers control.

  14. 14.A predecessor edge is removed but its phi operand remains. What needs repair?

    Show answer and explanation
    1. Block numbering
    2. The printed order of function declarations
    3. Edge-value consistency
    4. Stack-frame alignment

    Answer: Edge-value consistency

    Structural updates must maintain the IR's edge-value invariants.

  15. 15.A critical edge is split. What must phi handling preserve?

    Show answer and explanation
    1. Path-specific values
    2. Copies of the first predecessor's value on every path
    3. The original number of predecessors at every join
    4. The same textual operand index after all edge changes

    Answer: Path-specific values

    Edge restructuring must preserve dataflow along that path.

  16. 16.A dataflow pass assumes one traversal is enough on a cyclic graph. What may be missing?

    Show answer and explanation
    1. Fixed-point solving
    2. A bigger symbol table
    3. One pass in source order despite cyclic propagation
    4. Only a faster worklist container

    Answer: Fixed-point solving

    Information may need repeated propagation through loops.

  17. 17.A monotone analysis over a finite-height lattice grows facts toward a bound. What supports termination?

    Show answer and explanation
    1. Monotone finite progress
    2. An arbitrary worklist order alone
    3. Repeated traversal without state change
    4. An unbounded sequence of stricter facts

    Answer: Monotone finite progress

    Monotonicity and finite height limit distinct state changes.

  18. 18.A worklist stops while changed facts have unprocessed dependents. What can happen?

    Show answer and explanation
    1. Only a different fixed point with all dependencies satisfied
    2. Guaranteed completeness once every node has been seen once
    3. No issue if each transfer function is individually monotone
    4. Incomplete propagation

    Answer: Incomplete propagation

    Changes must propagate to affected nodes before convergence is claimed.

  19. 19.A may-analysis joins branch facts by union. What does that preserve?

    Show answer and explanation
    1. Facts true on every path
    2. The first branch's facts only
    3. Only equal constants from both inputs
    4. Possibilities from either path

    Answer: Possibilities from either path

    May information conservatively includes any incoming possibility.

  20. 20.A must-analysis joins branch facts. What generally matters?

    Show answer and explanation
    1. Any fact from either path
    2. Facts true on all paths
    3. The longest branch's facts only
    4. The final textual statement's facts

    Answer: Facts true on all paths

    Must properties require agreement across paths.

  21. 21.A value is constant 7 on one branch and 9 on another. What is safe at the join without path information?

    Show answer and explanation
    1. It is always seven.
    2. It is always nine.
    3. It is not one proven constant.
    4. It is the arithmetic mean eight.

    Answer: It is not one proven constant.

    Different reachable values cannot be replaced by an arbitrary average.

  22. 22.A branch condition is proven false. What can simplification remove?

    Show answer and explanation
    1. The unreachable successor, with required repairs
    2. The entire function
    3. Every effect on the reachable alternative
    4. All exception edges regardless of feasibility

    Answer: The unreachable successor, with required repairs

    Unreachable-edge removal still requires structural and semantic consistency.

  23. 23.A simplifier proves x*x is nonnegative using mathematical integers, but x is fixed-width signed with wrapping. What must be checked?

    Show answer and explanation
    1. Multiplication latency
    2. Actual arithmetic semantics
    3. The algebra of unbounded integers alone
    4. The variable's register class

    Answer: Actual arithmetic semantics

    Mathematical identities may fail under bounded or different overflow rules.

  24. 24.Under supplied 8-bit unsigned wrap, what is 255+2?

    Show answer and explanation
    1. 257
    2. 1
    3. 255
    4. 0

    Answer: 1

    257 modulo 256 equals one.

  25. 25.Under supplied signed overflow trapping, can x+1 be replaced by an unchecked machine add universally?

    Show answer and explanation
    1. No; preserve overflow behavior.
    2. Yes; all additions have the same overflow contract.
    3. Yes; a faster instruction defines the source result.
    4. No; no machine instruction can implement addition.

    Answer: No; preserve overflow behavior.

    The target operation must implement the source contract.

  26. 26.A floating-point rewrite reassociates (a+b)+c to a+(b+c). What can differ?

    Show answer and explanation
    1. Only register numbering
    2. Only instruction addresses after scheduling
    3. No result under every floating contract
    4. Rounding and exceptions

    Answer: Rounding and exceptions

    Floating arithmetic is not universally associative.

  27. 27.A rewrite replaces x*0 with positive zero. What must be considered for floating values?

    Show answer and explanation
    1. Floating special-value semantics
    2. Only whether x is mathematically finite in real arithmetic
    3. Only the multiplication's latency on the target
    4. Only whether the resulting zero has the same width

    Answer: Floating special-value semantics

    Floating special values and allowed semantics affect legality.

  28. 28.A floating x/x becomes 1 without constraints. What cases challenge it?

    Show answer and explanation
    1. Only values strictly between one and two
    2. Only distinct register assignments for the operands
    3. Special floating values
    4. Only ordinary finite nonzero operands

    Answer: Special floating values

    The rewrite needs assumptions excluding problematic floating values.

  29. 29.A fast-math flag permits a specific relaxation. What should an optimizer avoid?

    Show answer and explanation
    1. Reading the actual flag contract
    2. Retaining behavior the flag does not relax
    3. Assuming broader permissions
    4. Testing relevant special values

    Answer: Assuming broader permissions

    Each permission has defined scope rather than universal arithmetic freedom.

  30. 30.An IR operation can produce poison under a violated flag. What must a rewrite respect?

    Show answer and explanation
    1. Integer algebra alone
    2. The source-level variable's spelling
    3. The opcode's benchmark frequency
    4. Poison propagation rules

    Answer: Poison propagation rules

    Undefined and deferred-undefined behavior have specific transformation rules.

  31. 31.A single freeze result is used twice. What property matters?

    Show answer and explanation
    1. A new unrelated value for each use
    2. Zero for every poisoned input
    3. Proof the input was initialized
    4. One stable chosen value

    Answer: One stable chosen value

    Freeze stabilizes an arbitrary permitted value under its contract.

  32. 32.A pass replaces one shared freeze with two independent freezes. What can change?

    Show answer and explanation
    1. Only the number of uses, with all value relations preserved
    2. Only register pressure, since each freeze is defined
    3. The relation between their chosen values
    4. No behavior, because both instructions have the same opcode

    Answer: The relation between their chosen values

    Two independent choices need not preserve equality of one shared choice.

  33. 33.An expression is redundant only on one path. What might partial redundancy elimination require?

    Show answer and explanation
    1. Unconditional deletion
    2. Duplicating all effectful operations
    3. Safe path-aware placement
    4. Ignoring operand availability

    Answer: Safe path-aware placement

    Elimination must preserve availability and effects on every path.

  34. 34.A loop carries a memory dependence between iterations. What can vectorization violate?

    Show answer and explanation
    1. Only the instruction count in the vector loop
    2. Only the arithmetic precision of an unrelated reduction
    3. Only the loop's estimated profitability
    4. Iteration dependencies

    Answer: Iteration dependencies

    Parallel execution is unsafe when it breaks relevant dependencies.

  35. 35.A vectorizer assumes pointers do not overlap without proof. What is the concern?

    Show answer and explanation
    1. Guaranteed memory independence
    2. A merely unprofitable but always legal transformation
    3. Unsound dependence assumptions
    4. Automatic pointer validation

    Answer: Unsound dependence assumptions

    Overlap can change the result of reordered loads and stores.

  36. 36.A runtime alias check guards a fast path. What must its condition establish?

    Show answer and explanation
    1. Nonnull pointers alone
    2. Different source names for the pointers
    3. Required independence
    4. A sufficiently large array length

    Answer: Required independence

    A guard must prove the actual preconditions of the optimized path.

  37. 37.A vector loop handles groups of four over ten elements. How many elements remain after two full groups?

    Show answer and explanation
    1. 4
    2. 6
    3. 0
    4. 2

    Answer: 2

    Two groups cover eight elements, leaving two.

  38. 38.A remainder loop is deleted for arbitrary lengths. What can be lost?

    Show answer and explanation
    1. Debug-only iterations
    2. Tail iterations
    3. The loop body's block labels
    4. Only unused induction metadata

    Answer: Tail iterations

    Lengths not divisible by the vector width still require correct processing.

  39. 39.An unroller duplicates a loop body containing an observable call. What must remain correct?

    Show answer and explanation
    1. Observable call count and order
    2. Only static instruction count
    3. Only generated variable names
    4. Only the loop's source location

    Answer: Observable call count and order

    Unrolling must preserve effects and handle iteration counts.

  40. 40.A loop executes three times and calls f once each iteration. How many calls must equivalent defined behavior retain absent allowed elimination?

    Show answer and explanation
    1. 2
    2. 6
    3. 1
    4. 3

    Answer: 3

    One call per iteration over three iterations gives three.

  41. 41.A loop transformation changes i<bound to i!=bound. What must be proven?

    Show answer and explanation
    1. Safe reachability of the bound
    2. Equal comparison costs
    3. That both operands have integer type
    4. That the loop is frequently executed

    Answer: Safe reachability of the bound

    Different comparisons can differ when steps skip the bound or overflow.

  42. 42.A loop counter wraps before reaching its exit condition. What should analysis respect?

    Show answer and explanation
    1. Unbounded integer induction alone
    2. Actual overflow semantics
    3. Only the initial counter value
    4. Only the number of syntactic loop exits

    Answer: Actual overflow semantics

    Bounded arithmetic can invalidate an unbounded trip-count argument.

  43. 43.A strength reduction changes multiplication to repeated addition. What needs review?

    Show answer and explanation
    1. Multiplication cost alone
    2. The formula over unbounded integers alone
    3. Bounded-arithmetic behavior
    4. The count of induction variables alone

    Answer: Bounded-arithmetic behavior

    Equivalent mathematical formulas may not preserve the language's bounded arithmetic behavior.

  44. 44.A pass changes signed comparison to unsigned comparison. What can differ?

    Show answer and explanation
    1. Only operand spelling
    2. Only addresses of the comparison instructions
    3. Ordering of negative values
    4. No result for any shared bit pattern

    Answer: Ordering of negative values

    Signedness changes the ordering interpretation.

  45. 45.Under a supplied signed 8-bit two's-complement interpretation, what value does bit pattern 11111111 represent?

    Show answer and explanation
    1. 255
    2. -1
    3. 1
    4. 127

    Answer: -1

    Two's-complement all-ones represents negative one.

  46. 46.In unsigned 8-bit interpretation, what numeric value does the bit pattern 11111111 represent?

    Show answer and explanation
    1. 255
    2. 256
    3. 127
    4. -1

    Answer: 255

    All eight bits set represent 2^8 minus one.

  47. 47.A cast is removed because source and destination have equal width. What must still be checked?

    Show answer and explanation
    1. Semantic interpretation
    2. Equal widths alone
    3. The cast's source location
    4. The original declaration order

    Answer: Semantic interpretation

    Equal storage width does not establish interchangeable signedness or type semantics.

  48. 48.A pointer-to-integer rewrite assumes all pointers are ordinary addresses. What needs review?

    Show answer and explanation
    1. The compiler host's pointer width alone
    2. Equal pointer and integer widths as complete proof
    3. The presence of an integer opcode for each operation
    4. Pointer semantics

    Answer: Pointer semantics

    Pointer representation and provenance rules may constrain transformations.

  49. 49.A load's alignment metadata is strengthened without proof. What can result?

    Show answer and explanation
    1. Unsound alignment assumptions
    2. Automatic runtime realignment
    3. A guaranteed harmless annotation change
    4. Only reduced debug precision

    Answer: Unsound alignment assumptions

    Metadata that asserts stronger facts must be justified.

  50. 50.A pass marks a possibly aliasing call as memory-free. What can downstream passes do incorrectly?

    Show answer and explanation
    1. Only spend more time analyzing the call
    2. Only lose optimization opportunities
    3. Only make instruction scheduling more conservative
    4. Misoptimize memory effects

    Answer: Misoptimize memory effects

    Unsound effect summaries can authorize invalid transformations.

  51. 51.A cached alias analysis is reused after pointer-relevant IR changes. What is required?

    Show answer and explanation
    1. Only rerunning the cost model
    2. Analysis update or invalidation
    3. Only updating the pass's timing statistics
    4. Reusing every cached fact because its type is unchanged

    Answer: Analysis update or invalidation

    Analysis facts can cease to hold after transformations.

  52. 52.A pass claims to preserve all analyses but changes control flow. What should be checked?

    Show answer and explanation
    1. Analysis preservation
    2. Only pass runtime
    3. Only the function's source name
    4. Only the analysis cache size

    Answer: Analysis preservation

    Incorrect preservation can feed stale facts to later passes.

  53. 53.A pass is correct alone but fails after another pass. What should debugging inspect?

    Show answer and explanation
    1. The last pass's name alone
    2. A presumption isolated tests prove pipeline composition
    3. Pass-boundary assumptions
    4. Only total compile duration

    Answer: Pass-boundary assumptions

    Pipeline order can expose invalidated invariants or hidden dependencies.

  54. 54.An IR verifier passes after a rewrite. What does that not prove by itself?

    Show answer and explanation
    1. Checked structural validity
    2. Semantic equivalence
    3. That the verifier completed its run
    4. That its tested invariants were examined

    Answer: Semantic equivalence

    Well-formed IR can still compute the wrong result.

  55. 55.Differential testing compares two compilers. What must be controlled?

    Show answer and explanation
    1. Only matching optimization levels by name
    2. Only obtaining equal exit codes from the compiler processes
    3. Only producing binaries of equal size
    4. Comparable defined executions

    Answer: Comparable defined executions

    Meaningful comparisons need comparable defined executions.

  56. 56.A test program has source-level undefined behavior. What limitation arises?

    Show answer and explanation
    1. The oracle may be invalid.
    2. Both outputs must still agree.
    3. Undefined behavior disables every optimization.
    4. The shorter executable is necessarily correct.

    Answer: The oracle may be invalid.

    Undefined source behavior can undermine a differential oracle.

  57. 57.A reducer minimizes a failing case. What must it preserve?

    Show answer and explanation
    1. Only source length
    2. Only the original function name
    3. Failure and validity conditions
    4. Only any nonzero compiler exit

    Answer: Failure and validity conditions

    A smaller case is useful only if it still demonstrates the issue.

  58. 58.A regression test checks an exact instruction sequence without need. What can be fragile?

    Show answer and explanation
    1. The semantic contract itself
    2. The fact the compiler has a target
    3. Incidental output coupling
    4. The source program's validity

    Answer: Incidental output coupling

    Tests should assert the behavior or required pattern rather than unnecessary detail.

  59. 59.A performance benchmark improves 5% but correctness tests fail. What is appropriate?

    Show answer and explanation
    1. Fix or reject it.
    2. Ship because the runtime improves.
    3. Delete the correctness case.
    4. Redefine the expected result to match output.

    Answer: Fix or reject it.

    Performance does not justify changing required behavior.

  60. 60.A benchmark is measured once on a noisy system. What is missing?

    Show answer and explanation
    1. Reliable repeated measurement and controls
    2. One more decimal place
    3. Only a different benchmark label
    4. The best run treated as representative

    Answer: Reliable repeated measurement and controls

    Noise and environment can explain an apparent gain.

  61. 61.Times are 100 ms before and 80 ms after. What is time reduction?

    Show answer and explanation
    1. 20%
    2. 125%
    3. 80%
    4. 25%

    Answer: 20%

    Twenty divided by the original one hundred equals 20%.

  62. 62.What is the speedup ratio for 100 ms versus 80 ms?

    Show answer and explanation
    1. 1.25×
    2. 0.8×
    3. 2×
    4. 1.2×

    Answer: 1.25×

    Old time divided by new time is 100/80=1.25.

  63. 63.A faster optimization greatly increases compile time. What should be evaluated?

    Show answer and explanation
    1. Only generated runtime
    2. Only peak instruction throughput
    3. Runtime and compilation tradeoffs
    4. Only the number of removed IR nodes

    Answer: Runtime and compilation tradeoffs

    Compiler choices may have multiple performance objectives and budgets.

  64. 64.A pass optimizes for one microarchitecture. What should legality remain distinct from?

    Show answer and explanation
    1. Profitability
    2. Defined behavior
    3. Representation invariants
    4. Required program meaning

    Answer: Profitability

    An optimization may be legal yet unprofitable on a particular target.

  65. 65.A profitability model predicts fewer instructions but more cache misses. What matters?

    Show answer and explanation
    1. Total target cost
    2. Instruction count alone
    3. Only assembly line count
    4. The number of virtual registers

    Answer: Total target cost

    Static instruction reduction does not guarantee faster execution.

  66. 66.Inlining exposes constants but increases code size. What tradeoff is relevant?

    Show answer and explanation
    1. Guaranteed speedup from every removed call
    2. Only fewer argument-register moves
    3. Opportunity versus code growth
    4. Only the reduced call-graph edge count

    Answer: Opportunity versus code growth

    Inlining can improve simplification while worsening instruction-cache behavior or size.

  67. 67.Inlining a function with exception handling requires what?

    Show answer and explanation
    1. Only copied arithmetic
    2. Only renamed parameters
    3. Exceptional exits and cleanup
    4. Only a larger frame allocation

    Answer: Exceptional exits and cleanup

    Calls can have exceptional exits and semantic obligations.

  68. 68.Tail-call elimination reuses a frame. What must be respected?

    Show answer and explanation
    1. Textual tail position alone
    2. ABI and lifetime constraints
    3. Equal result types alone
    4. Identical argument counts alone

    Answer: ABI and lifetime constraints

    A syntactic tail position does not settle every ABI and lifetime condition.

  69. 69.A dead function appears unused locally but is externally visible. What must elimination consider?

    Show answer and explanation
    1. Local call count alone
    2. Only function body size
    3. Only compilation cost
    4. External reachability

    Answer: External reachability

    Other translation units or runtime mechanisms may reference it.

  70. 70.Whole-program analysis assumes no external callers. What should establish that assumption?

    Show answer and explanation
    1. A valid closed-world contract
    2. No local direct caller alone
    3. A hidden-visibility assumption without checking linkage
    4. A high optimization setting alone

    Answer: A valid closed-world contract

    Closed-world assumptions need a valid compilation and linking contract.

  71. 71.A function address is stored in a table. What should reachability account for?

    Show answer and explanation
    1. Only direct call instructions
    2. Only functions exported by name
    3. Only functions appearing in the entry block
    4. Indirect references

    Answer: Indirect references

    Indirect references can keep functions semantically reachable.

  72. 72.A branch profile says one path is rare. Can the compiler delete it solely for rarity?

    Show answer and explanation
    1. Yes; rare means impossible.
    2. Yes; a profile establishes semantic unreachability.
    3. No; rare behavior still matters.
    4. No; profile data can never guide code layout.

    Answer: No; rare behavior still matters.

    Frequency is not a proof that a path cannot execute.

  73. 73.A profile was collected before a major workload change. What should be assessed?

    Show answer and explanation
    1. The profile's extension
    2. Profile relevance
    3. Only the largest observed counter
    4. A guarantee profiles remain representative forever

    Answer: Profile relevance

    Stale profiles may misguide profitability even when legality is preserved.

  74. 74.A transformation uses a profile count as a nonnull proof. What is wrong?

    Show answer and explanation
    1. Samples establish all future values.
    2. Samples are not universal proof.
    3. A hot path cannot have defined null inputs.
    4. Nonnull depends only on the number of observations.

    Answer: Samples are not universal proof.

    Speculative assumptions need valid guards or contractual proof.

  75. 75.A speculative optimization adds a guard and fallback. What must be preserved?

    Show answer and explanation
    1. The fast path alone
    2. Correct guards and fallback
    3. Only the common benchmark input
    4. Only the new branch layout

    Answer: Correct guards and fallback

    Speculation is sound only when failed assumptions lead to correct handling.

  76. 76.Deoptimization reconstructs variables from optimized state. What information is needed?

    Show answer and explanation
    1. The source text alone
    2. Only the final physical-register count
    3. The optimized executable's size
    4. Accurate state mapping

    Answer: Accurate state mapping

    A fallback must resume with the required program state.

  77. 77.A pass removes a value needed only for deoptimization. What must it consider?

    Show answer and explanation
    1. Ordinary arithmetic uses only
    2. Only values live in the fast-path machine code
    3. Only externally visible global variables
    4. Deoptimization uses

    Answer: Deoptimization uses

    Runtime state reconstruction can make values necessary beyond ordinary dataflow.

  78. 78.A loop has an early exit with observable effects. What must vectorization preserve?

    Show answer and explanation
    1. The final trip count alone
    2. Exit and effect semantics
    3. Only the successful full-vector path
    4. Only the numeric value returned at normal exit

    Answer: Exit and effect semantics

    Early exits complicate which iterations and effects are allowed to occur.

  79. 79.A rewrite speculates a load from an invalid address on a previously untaken path. What can change?

    Show answer and explanation
    1. Only register pressure
    2. Only the number of instructions on the original path
    3. New memory-fault behavior
    4. No behavior because the loaded value is later unused

    Answer: New memory-fault behavior

    Adding an executed memory access can introduce behavior absent before.

  80. 80.A store-to-load forwarding rule ignores access width. What should be checked?

    Show answer and explanation
    1. Memory ranges and interpretation
    2. Pointer spelling alone
    3. The most recent store regardless of width
    4. Only source-text proximity

    Answer: Memory ranges and interpretation

    Partial or differently interpreted stores may not supply the entire loaded value.

  81. 81.A store defines four bytes beginning at address P. A later load reads eight bytes beginning at P, with no information about the other four bytes. Does that store alone establish the entire loaded value?

    Show answer and explanation
    1. Yes; a shared start address defines all eight bytes.
    2. No; only half is established.
    3. Yes; the load automatically truncates itself to four bytes.
    4. No; forwarding is never valid for any load.

    Answer: No; only half is established.

    The supplied store covers only part of the load.

  82. 82.Two stores overlap by two bytes. What analysis matters?

    Show answer and explanation
    1. Instruction count alone
    2. Only the source variable names
    3. Byte overlap and order
    4. Only access cost estimates

    Answer: Byte overlap and order

    Overlapping byte ranges can affect the later observed contents.

  83. 83.A pass simplifies a comparison using a range fact from a branch. What must hold?

    Show answer and explanation
    1. The check occurred somewhere.
    2. Valid facts on all affected paths
    3. The value once had that range before reassignment.
    4. The branch was frequently taken in a profile.

    Answer: Valid facts on all affected paths

    Path-dependent facts cannot be applied outside their valid region.

  84. 84.A variable is assigned after a range check. What should happen to a stale range fact?

    Show answer and explanation
    1. Retain the old range forever.
    2. Treat the assignment as semantically empty.
    3. Assume the new value inherits every prior bound.
    4. Invalidate stale facts.

    Answer: Invalidate stale facts.

    Dataflow facts depend on the actual definition and state.

  85. 85.A transformation duplicates a nondeterministic operation. What can change?

    Show answer and explanation
    1. Only execution cost when each copy has the same opcode
    2. Only code size if the operation is individually valid
    3. No behavior because both operations return the same type
    4. Result relationships and effects

    Answer: Result relationships and effects

    One choice reused and multiple independent choices can differ semantically.

  86. 86.An optimizer assumes a library call's behavior from its name. What should be verified?

    Show answer and explanation
    1. Spelling alone
    2. Recognized semantics and linkage
    3. Only the apparent argument count
    4. Only the return register

    Answer: Recognized semantics and linkage

    A symbol's name alone may not establish builtin semantics in every context.

  87. 87.An integer constant fold uses the compiler host's endianness for target memory bytes. What is needed?

    Show answer and explanation
    1. Target layout
    2. Host layout alone
    3. Only the literal's source encoding
    4. Only the optimization level

    Answer: Target layout

    Cross-compilation must respect target interpretation.

  88. 88.A pass drops exception edges when merging blocks. What can be lost?

    Show answer and explanation
    1. Only the normal successor's instruction count
    2. Only the ordinary return value
    3. No behavior if both blocks end in a branch
    4. Exception behavior

    Answer: Exception behavior

    Control-flow simplification must preserve permitted exception paths.

  89. 89.A pass moves cleanup after a return. What should validation examine?

    Show answer and explanation
    1. Required cleanup execution
    2. Total instruction count alone
    3. Only textual source order
    4. Only whether the function has a cleanup label

    Answer: Required cleanup execution

    Cleanup may be observable and must occur according to the language contract.

  90. 90.A pass preserves values but changes required synchronization. Is value equality alone sufficient?

    Show answer and explanation
    1. Yes; final scalar equality covers every concurrent execution.
    2. Yes; synchronization is always a performance hint.
    3. No; this makes all optimization impossible.
    4. No; concurrency also matters.

    Answer: No; concurrency also matters.

    Concurrency can add behavioral requirements beyond one sequential result.

  91. 91.A transformation proof assumes an unreachable block is truly unreachable. What must support this?

    Show answer and explanation
    1. Low profile frequency
    2. Sound unreachability evidence
    3. The block's lack of an ordinary predecessor, ignoring exceptional edges
    4. An unverified assertion from a prior transformation

    Answer: Sound unreachability evidence

    Unreachability requires more than rarity or intention.

  92. 92.An analysis deliberately overapproximates possible values. Why can that help correctness?

    Show answer and explanation
    1. Preserving feasible behaviors
    2. It maximizes every optimization.
    3. It proves every listed value must occur.
    4. It removes the need for semantic assumptions.

    Answer: Preserving feasible behaviors

    Conservative analysis may lose precision while preserving safety for its use.

  93. 93.An analysis underapproximates aliases used to justify reordering. What risk arises?

    Show answer and explanation
    1. Only missed opportunities
    2. An actual overlap may be treated as independent, causing wrong code.
    3. Guaranteed conservative independence
    4. Automatic memory safety

    Answer: An actual overlap may be treated as independent, causing wrong code.

    Omitting a feasible alias can authorize an invalid transformation.

  94. 94.A legal optimization is skipped due to conservative analysis. What is the usual result?

    Show answer and explanation
    1. Wrong behavior by definition
    2. An invalid source program
    3. A guaranteed compiler crash
    4. Lost optimization

    Answer: Lost optimization

    Conservatism can sacrifice profitability without violating semantics.

  95. 95.A solver proves equivalence under a restricted model. What should the claim disclose?

    Show answer and explanation
    1. Assumptions and proof scope
    2. A guarantee for every target representation
    3. Only the number of solver queries
    4. Only agreement on sampled test inputs

    Answer: Assumptions and proof scope

    Formal evidence is limited by the semantics and assumptions encoded.

  96. 96.A proof omits floating exception flags required by the contract. What is the gap?

    Show answer and explanation
    1. Only code size uncertainty
    2. A guarantee flags are irrelevant
    3. Missing observable behavior
    4. Proof that the missing effects cannot occur

    Answer: Missing observable behavior

    A proof must cover the behaviors the implementation must preserve.

  97. 97.A pass is nondeterministic because worklist order changes output. What should be distinguished?

    Show answer and explanation
    1. Every output difference as a correctness bug
    2. Validity versus reproducibility
    3. Every nondeterministic output as harmless
    4. Only the file timestamp

    Answer: Validity versus reproducibility

    Multiple outputs can be valid, but semantic and reproducibility requirements need review.

  98. 98.An optimization bug occurs only after repeated pass execution. What should be checked?

    Show answer and explanation
    1. Only the first successful run
    2. Preserved invariants
    3. Only the pass's textual name
    4. Only benchmark initialization

    Answer: Preserved invariants

    Repeated transforms can expose accumulating errors or invalid assumptions.

  99. 99.A candidate proposes a rewrite without stating preconditions. What should be requested?

    Show answer and explanation
    1. Only an expected speedup
    2. A legality argument
    3. Only the shorter expression
    4. Only an assembly screenshot

    Answer: A legality argument

    Transformations need explicit assumptions and semantic reasoning.

  100. 100.A supplied IR freeze selects one arbitrary defined i8 value shared by all uses of its result. Original code emits v and v XOR 0x0F, using one v=freeze(poison). A pass gives the two emissions independent freezes. Which original guarantee can be lost?

    Show answer and explanation
    1. Both outputs are valid i8 values.
    2. At least one output is always zero.
    3. The original outputs were independent choices.
    4. XOR of the two emitted values equals 0x0F.

    Answer: XOR of the two emitted values equals 0x0F.

    Originally v XOR (v XOR 0x0F)=0x0F. Independent choices a and b instead give a XOR b XOR 0x0F, which need not equal 0x0F. Defined output values alone do not preserve their relationship.

  101. 101.In a single-threaded supplied memory model, p and q address valid ordinary 32-bit cells with no volatile or atomic effects. Code stores 7 through p, then loads through q and returns that value. Which additional fact justifies moving the load before the store for every initial value?

    Show answer and explanation
    1. Both pointers have the same element type.
    2. The read and write access ranges do not overlap.
    3. The load result has only one use.
    4. The source names p and q are different.

    Answer: The read and write access ranges do not overlap.

    Disjoint ranges make the store unable to change the load. Equal types, distinct names, or use count do not prove that fact; if p and q alias, the original observes seven while a hoisted load may observe the old value.