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.An optimization produces faster output but changes a defined program result. What failed?
Show answer and explanation
- IR well-formedness
- Semantic preservation
- Register-pressure profitability
- Source-location fidelity
Answer: Semantic preservation
Optimization must preserve the relevant observable behavior.
2.A rewrite is correct only when x is nonzero. What must justify applying it?
Show answer and explanation
- A valid nonzero proof
- A frequent input value
- A profile with no observed zero
- A favorable cost estimate
Answer: A valid nonzero proof
A precondition must hold for every affected defined execution.
3.An analysis says two pointers may alias. What may the optimizer safely infer?
Show answer and explanation
- Proven disjointness
- Possible overlap
- Equality of the pointers' loaded values
- Interchangeable access semantics
Answer: Possible overlap
May-alias is conservative uncertainty, not proof of independence.
4.A load is moved before a potentially aliasing store. What proof is needed?
Show answer and explanation
- Lower load latency
- The source order of the instructions
- Equal operand type names
- Preserved memory behavior
Answer: Preserved memory behavior
Memory dependence can make reordering observable.
5.An unknown call lies between two loads. What must common-subexpression elimination consider?
Show answer and explanation
- The call's cost
- Its argument count without memory-effect information
- Possible memory modification
- The load's register class
Answer: Possible memory modification
A call may invalidate a previously loaded value.
6.A store is deleted because no local load follows. What else matters?
Show answer and explanation
- Local use count alone
- The stored value's frequency in benchmarks
- The assignment's source line
- Observable memory uses
Answer: Observable memory uses
Escaping memory and later callers can observe the store.
7.A volatile access appears unused. What should deletion consider?
Show answer and explanation
- The result's deadness alone
- The access's arithmetic value without observable access rules
- Its required observable access semantics
- The instruction's cost
Answer: Its required observable access semantics
Volatile operations can be observable independently of value use.
8.Two atomic operations are reordered. What must remain valid?
Show answer and explanation
- Only final local values
- The number of instructions in the block
- Memory ordering
- The chosen register order
Answer: Memory ordering
Concurrent semantics can constrain transformations beyond local arithmetic.
9.A loop-invariant divide may trap on a path where the loop never runs. What can hoisting change?
Show answer and explanation
- Only the divide's result precision
- Only the number of loop-body instructions
- Trap occurrence
- Only spill placement inside the loop
Answer: Trap occurrence
Speculating a potentially trapping operation can add behavior.
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
- It must violate dominance despite the stated proof.
- Every invariant expression changes overflow semantics.
- It performs the work on zero-iteration executions.
- 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.A transformation moves a computation to a block not dominated by its definition. What invariant can fail?
Show answer and explanation
- Register affinity
- Instruction selection profitability
- Symbol visibility
- Operand availability
Answer: Operand availability
An operand must be available on every path reaching its use.
12.In SSA, a definition dominates an ordinary use. What does that require?
Show answer and explanation
- The definition is textually earlier somewhere.
- All relevant paths cross the definition.
- The definition has more uses than other values.
- The containing blocks have equal sizes.
Answer: All relevant paths cross the definition.
Dominance is a control-flow path property.
13.A join receives values from two predecessor edges. What does a phi select by?
Show answer and explanation
- The larger numeric operand
- The first listed value on every execution
- The earliest source declaration
- The incoming control-flow edge
Answer: The incoming control-flow edge
Phi semantics are associated with the predecessor that transfers control.
14.A predecessor edge is removed but its phi operand remains. What needs repair?
Show answer and explanation
- Block numbering
- The printed order of function declarations
- Edge-value consistency
- Stack-frame alignment
Answer: Edge-value consistency
Structural updates must maintain the IR's edge-value invariants.
15.A critical edge is split. What must phi handling preserve?
Show answer and explanation
- Path-specific values
- Copies of the first predecessor's value on every path
- The original number of predecessors at every join
- The same textual operand index after all edge changes
Answer: Path-specific values
Edge restructuring must preserve dataflow along that path.
16.A dataflow pass assumes one traversal is enough on a cyclic graph. What may be missing?
Show answer and explanation
- Fixed-point solving
- A bigger symbol table
- One pass in source order despite cyclic propagation
- Only a faster worklist container
Answer: Fixed-point solving
Information may need repeated propagation through loops.
17.A monotone analysis over a finite-height lattice grows facts toward a bound. What supports termination?
Show answer and explanation
- Monotone finite progress
- An arbitrary worklist order alone
- Repeated traversal without state change
- An unbounded sequence of stricter facts
Answer: Monotone finite progress
Monotonicity and finite height limit distinct state changes.
18.A worklist stops while changed facts have unprocessed dependents. What can happen?
Show answer and explanation
- Only a different fixed point with all dependencies satisfied
- Guaranteed completeness once every node has been seen once
- No issue if each transfer function is individually monotone
- Incomplete propagation
Answer: Incomplete propagation
Changes must propagate to affected nodes before convergence is claimed.
19.A may-analysis joins branch facts by union. What does that preserve?
Show answer and explanation
- Facts true on every path
- The first branch's facts only
- Only equal constants from both inputs
- Possibilities from either path
Answer: Possibilities from either path
May information conservatively includes any incoming possibility.
20.A must-analysis joins branch facts. What generally matters?
Show answer and explanation
- Any fact from either path
- Facts true on all paths
- The longest branch's facts only
- The final textual statement's facts
Answer: Facts true on all paths
Must properties require agreement across paths.
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
- It is always seven.
- It is always nine.
- It is not one proven constant.
- It is the arithmetic mean eight.
Answer: It is not one proven constant.
Different reachable values cannot be replaced by an arbitrary average.
22.A branch condition is proven false. What can simplification remove?
Show answer and explanation
- The unreachable successor, with required repairs
- The entire function
- Every effect on the reachable alternative
- All exception edges regardless of feasibility
Answer: The unreachable successor, with required repairs
Unreachable-edge removal still requires structural and semantic consistency.
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
- Multiplication latency
- Actual arithmetic semantics
- The algebra of unbounded integers alone
- The variable's register class
Answer: Actual arithmetic semantics
Mathematical identities may fail under bounded or different overflow rules.
24.Under supplied 8-bit unsigned wrap, what is 255+2?
Show answer and explanation
- 257
- 1
- 255
- 0
Answer: 1
257 modulo 256 equals one.
25.Under supplied signed overflow trapping, can x+1 be replaced by an unchecked machine add universally?
Show answer and explanation
- No; preserve overflow behavior.
- Yes; all additions have the same overflow contract.
- Yes; a faster instruction defines the source result.
- No; no machine instruction can implement addition.
Answer: No; preserve overflow behavior.
The target operation must implement the source contract.
26.A floating-point rewrite reassociates (a+b)+c to a+(b+c). What can differ?
Show answer and explanation
- Only register numbering
- Only instruction addresses after scheduling
- No result under every floating contract
- Rounding and exceptions
Answer: Rounding and exceptions
Floating arithmetic is not universally associative.
27.A rewrite replaces x*0 with positive zero. What must be considered for floating values?
Show answer and explanation
- Floating special-value semantics
- Only whether x is mathematically finite in real arithmetic
- Only the multiplication's latency on the target
- Only whether the resulting zero has the same width
Answer: Floating special-value semantics
Floating special values and allowed semantics affect legality.
28.A floating x/x becomes 1 without constraints. What cases challenge it?
Show answer and explanation
- Only values strictly between one and two
- Only distinct register assignments for the operands
- Special floating values
- Only ordinary finite nonzero operands
Answer: Special floating values
The rewrite needs assumptions excluding problematic floating values.
29.A fast-math flag permits a specific relaxation. What should an optimizer avoid?
Show answer and explanation
- Reading the actual flag contract
- Retaining behavior the flag does not relax
- Assuming broader permissions
- Testing relevant special values
Answer: Assuming broader permissions
Each permission has defined scope rather than universal arithmetic freedom.
30.An IR operation can produce poison under a violated flag. What must a rewrite respect?
Show answer and explanation
- Integer algebra alone
- The source-level variable's spelling
- The opcode's benchmark frequency
- Poison propagation rules
Answer: Poison propagation rules
Undefined and deferred-undefined behavior have specific transformation rules.
31.A single freeze result is used twice. What property matters?
Show answer and explanation
- A new unrelated value for each use
- Zero for every poisoned input
- Proof the input was initialized
- One stable chosen value
Answer: One stable chosen value
Freeze stabilizes an arbitrary permitted value under its contract.
32.A pass replaces one shared freeze with two independent freezes. What can change?
Show answer and explanation
- Only the number of uses, with all value relations preserved
- Only register pressure, since each freeze is defined
- The relation between their chosen values
- 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.An expression is redundant only on one path. What might partial redundancy elimination require?
Show answer and explanation
- Unconditional deletion
- Duplicating all effectful operations
- Safe path-aware placement
- Ignoring operand availability
Answer: Safe path-aware placement
Elimination must preserve availability and effects on every path.
34.A loop carries a memory dependence between iterations. What can vectorization violate?
Show answer and explanation
- Only the instruction count in the vector loop
- Only the arithmetic precision of an unrelated reduction
- Only the loop's estimated profitability
- Iteration dependencies
Answer: Iteration dependencies
Parallel execution is unsafe when it breaks relevant dependencies.
35.A vectorizer assumes pointers do not overlap without proof. What is the concern?
Show answer and explanation
- Guaranteed memory independence
- A merely unprofitable but always legal transformation
- Unsound dependence assumptions
- Automatic pointer validation
Answer: Unsound dependence assumptions
Overlap can change the result of reordered loads and stores.
36.A runtime alias check guards a fast path. What must its condition establish?
Show answer and explanation
- Nonnull pointers alone
- Different source names for the pointers
- Required independence
- A sufficiently large array length
Answer: Required independence
A guard must prove the actual preconditions of the optimized path.
37.A vector loop handles groups of four over ten elements. How many elements remain after two full groups?
Show answer and explanation
- 4
- 6
- 0
- 2
Answer: 2
Two groups cover eight elements, leaving two.
38.A remainder loop is deleted for arbitrary lengths. What can be lost?
Show answer and explanation
- Debug-only iterations
- Tail iterations
- The loop body's block labels
- Only unused induction metadata
Answer: Tail iterations
Lengths not divisible by the vector width still require correct processing.
39.An unroller duplicates a loop body containing an observable call. What must remain correct?
Show answer and explanation
- Observable call count and order
- Only static instruction count
- Only generated variable names
- Only the loop's source location
Answer: Observable call count and order
Unrolling must preserve effects and handle iteration counts.
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
- 2
- 6
- 1
- 3
Answer: 3
One call per iteration over three iterations gives three.
41.A loop transformation changes i<bound to i!=bound. What must be proven?
Show answer and explanation
- Safe reachability of the bound
- Equal comparison costs
- That both operands have integer type
- That the loop is frequently executed
Answer: Safe reachability of the bound
Different comparisons can differ when steps skip the bound or overflow.
42.A loop counter wraps before reaching its exit condition. What should analysis respect?
Show answer and explanation
- Unbounded integer induction alone
- Actual overflow semantics
- Only the initial counter value
- Only the number of syntactic loop exits
Answer: Actual overflow semantics
Bounded arithmetic can invalidate an unbounded trip-count argument.
43.A strength reduction changes multiplication to repeated addition. What needs review?
Show answer and explanation
- Multiplication cost alone
- The formula over unbounded integers alone
- Bounded-arithmetic behavior
- The count of induction variables alone
Answer: Bounded-arithmetic behavior
Equivalent mathematical formulas may not preserve the language's bounded arithmetic behavior.
44.A pass changes signed comparison to unsigned comparison. What can differ?
Show answer and explanation
- Only operand spelling
- Only addresses of the comparison instructions
- Ordering of negative values
- No result for any shared bit pattern
Answer: Ordering of negative values
Signedness changes the ordering interpretation.
45.Under a supplied signed 8-bit two's-complement interpretation, what value does bit pattern 11111111 represent?
Show answer and explanation
- 255
- -1
- 1
- 127
Answer: -1
Two's-complement all-ones represents negative one.
46.In unsigned 8-bit interpretation, what numeric value does the bit pattern 11111111 represent?
Show answer and explanation
- 255
- 256
- 127
- -1
Answer: 255
All eight bits set represent 2^8 minus one.
47.A cast is removed because source and destination have equal width. What must still be checked?
Show answer and explanation
- Semantic interpretation
- Equal widths alone
- The cast's source location
- The original declaration order
Answer: Semantic interpretation
Equal storage width does not establish interchangeable signedness or type semantics.
48.A pointer-to-integer rewrite assumes all pointers are ordinary addresses. What needs review?
Show answer and explanation
- The compiler host's pointer width alone
- Equal pointer and integer widths as complete proof
- The presence of an integer opcode for each operation
- Pointer semantics
Answer: Pointer semantics
Pointer representation and provenance rules may constrain transformations.
49.A load's alignment metadata is strengthened without proof. What can result?
Show answer and explanation
- Unsound alignment assumptions
- Automatic runtime realignment
- A guaranteed harmless annotation change
- Only reduced debug precision
Answer: Unsound alignment assumptions
Metadata that asserts stronger facts must be justified.
50.A pass marks a possibly aliasing call as memory-free. What can downstream passes do incorrectly?
Show answer and explanation
- Only spend more time analyzing the call
- Only lose optimization opportunities
- Only make instruction scheduling more conservative
- Misoptimize memory effects
Answer: Misoptimize memory effects
Unsound effect summaries can authorize invalid transformations.
51.A cached alias analysis is reused after pointer-relevant IR changes. What is required?
Show answer and explanation
- Only rerunning the cost model
- Analysis update or invalidation
- Only updating the pass's timing statistics
- Reusing every cached fact because its type is unchanged
Answer: Analysis update or invalidation
Analysis facts can cease to hold after transformations.
52.A pass claims to preserve all analyses but changes control flow. What should be checked?
Show answer and explanation
- Analysis preservation
- Only pass runtime
- Only the function's source name
- Only the analysis cache size
Answer: Analysis preservation
Incorrect preservation can feed stale facts to later passes.
53.A pass is correct alone but fails after another pass. What should debugging inspect?
Show answer and explanation
- The last pass's name alone
- A presumption isolated tests prove pipeline composition
- Pass-boundary assumptions
- Only total compile duration
Answer: Pass-boundary assumptions
Pipeline order can expose invalidated invariants or hidden dependencies.
54.An IR verifier passes after a rewrite. What does that not prove by itself?
Show answer and explanation
- Checked structural validity
- Semantic equivalence
- That the verifier completed its run
- That its tested invariants were examined
Answer: Semantic equivalence
Well-formed IR can still compute the wrong result.
55.Differential testing compares two compilers. What must be controlled?
Show answer and explanation
- Only matching optimization levels by name
- Only obtaining equal exit codes from the compiler processes
- Only producing binaries of equal size
- Comparable defined executions
Answer: Comparable defined executions
Meaningful comparisons need comparable defined executions.
56.A test program has source-level undefined behavior. What limitation arises?
Show answer and explanation
- The oracle may be invalid.
- Both outputs must still agree.
- Undefined behavior disables every optimization.
- The shorter executable is necessarily correct.
Answer: The oracle may be invalid.
Undefined source behavior can undermine a differential oracle.
57.A reducer minimizes a failing case. What must it preserve?
Show answer and explanation
- Only source length
- Only the original function name
- Failure and validity conditions
- Only any nonzero compiler exit
Answer: Failure and validity conditions
A smaller case is useful only if it still demonstrates the issue.
58.A regression test checks an exact instruction sequence without need. What can be fragile?
Show answer and explanation
- The semantic contract itself
- The fact the compiler has a target
- Incidental output coupling
- The source program's validity
Answer: Incidental output coupling
Tests should assert the behavior or required pattern rather than unnecessary detail.
59.A performance benchmark improves 5% but correctness tests fail. What is appropriate?
Show answer and explanation
- Fix or reject it.
- Ship because the runtime improves.
- Delete the correctness case.
- Redefine the expected result to match output.
Answer: Fix or reject it.
Performance does not justify changing required behavior.
60.A benchmark is measured once on a noisy system. What is missing?
Show answer and explanation
- Reliable repeated measurement and controls
- One more decimal place
- Only a different benchmark label
- The best run treated as representative
Answer: Reliable repeated measurement and controls
Noise and environment can explain an apparent gain.
61.Times are 100 ms before and 80 ms after. What is time reduction?
Show answer and explanation
- 20%
- 125%
- 80%
- 25%
Answer: 20%
Twenty divided by the original one hundred equals 20%.
62.What is the speedup ratio for 100 ms versus 80 ms?
Show answer and explanation
- 1.25×
- 0.8×
- 2×
- 1.2×
Answer: 1.25×
Old time divided by new time is 100/80=1.25.
63.A faster optimization greatly increases compile time. What should be evaluated?
Show answer and explanation
- Only generated runtime
- Only peak instruction throughput
- Runtime and compilation tradeoffs
- Only the number of removed IR nodes
Answer: Runtime and compilation tradeoffs
Compiler choices may have multiple performance objectives and budgets.
64.A pass optimizes for one microarchitecture. What should legality remain distinct from?
Show answer and explanation
- Profitability
- Defined behavior
- Representation invariants
- Required program meaning
Answer: Profitability
An optimization may be legal yet unprofitable on a particular target.
65.A profitability model predicts fewer instructions but more cache misses. What matters?
Show answer and explanation
- Total target cost
- Instruction count alone
- Only assembly line count
- The number of virtual registers
Answer: Total target cost
Static instruction reduction does not guarantee faster execution.
66.Inlining exposes constants but increases code size. What tradeoff is relevant?
Show answer and explanation
- Guaranteed speedup from every removed call
- Only fewer argument-register moves
- Opportunity versus code growth
- Only the reduced call-graph edge count
Answer: Opportunity versus code growth
Inlining can improve simplification while worsening instruction-cache behavior or size.
67.Inlining a function with exception handling requires what?
Show answer and explanation
- Only copied arithmetic
- Only renamed parameters
- Exceptional exits and cleanup
- Only a larger frame allocation
Answer: Exceptional exits and cleanup
Calls can have exceptional exits and semantic obligations.
68.Tail-call elimination reuses a frame. What must be respected?
Show answer and explanation
- Textual tail position alone
- ABI and lifetime constraints
- Equal result types alone
- Identical argument counts alone
Answer: ABI and lifetime constraints
A syntactic tail position does not settle every ABI and lifetime condition.
69.A dead function appears unused locally but is externally visible. What must elimination consider?
Show answer and explanation
- Local call count alone
- Only function body size
- Only compilation cost
- External reachability
Answer: External reachability
Other translation units or runtime mechanisms may reference it.
70.Whole-program analysis assumes no external callers. What should establish that assumption?
Show answer and explanation
- A valid closed-world contract
- No local direct caller alone
- A hidden-visibility assumption without checking linkage
- A high optimization setting alone
Answer: A valid closed-world contract
Closed-world assumptions need a valid compilation and linking contract.
71.A function address is stored in a table. What should reachability account for?
Show answer and explanation
- Only direct call instructions
- Only functions exported by name
- Only functions appearing in the entry block
- Indirect references
Answer: Indirect references
Indirect references can keep functions semantically reachable.
72.A branch profile says one path is rare. Can the compiler delete it solely for rarity?
Show answer and explanation
- Yes; rare means impossible.
- Yes; a profile establishes semantic unreachability.
- No; rare behavior still matters.
- 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.A profile was collected before a major workload change. What should be assessed?
Show answer and explanation
- The profile's extension
- Profile relevance
- Only the largest observed counter
- A guarantee profiles remain representative forever
Answer: Profile relevance
Stale profiles may misguide profitability even when legality is preserved.
74.A transformation uses a profile count as a nonnull proof. What is wrong?
Show answer and explanation
- Samples establish all future values.
- Samples are not universal proof.
- A hot path cannot have defined null inputs.
- Nonnull depends only on the number of observations.
Answer: Samples are not universal proof.
Speculative assumptions need valid guards or contractual proof.
75.A speculative optimization adds a guard and fallback. What must be preserved?
Show answer and explanation
- The fast path alone
- Correct guards and fallback
- Only the common benchmark input
- Only the new branch layout
Answer: Correct guards and fallback
Speculation is sound only when failed assumptions lead to correct handling.
76.Deoptimization reconstructs variables from optimized state. What information is needed?
Show answer and explanation
- The source text alone
- Only the final physical-register count
- The optimized executable's size
- Accurate state mapping
Answer: Accurate state mapping
A fallback must resume with the required program state.
77.A pass removes a value needed only for deoptimization. What must it consider?
Show answer and explanation
- Ordinary arithmetic uses only
- Only values live in the fast-path machine code
- Only externally visible global variables
- Deoptimization uses
Answer: Deoptimization uses
Runtime state reconstruction can make values necessary beyond ordinary dataflow.
78.A loop has an early exit with observable effects. What must vectorization preserve?
Show answer and explanation
- The final trip count alone
- Exit and effect semantics
- Only the successful full-vector path
- 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.A rewrite speculates a load from an invalid address on a previously untaken path. What can change?
Show answer and explanation
- Only register pressure
- Only the number of instructions on the original path
- New memory-fault behavior
- 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.A store-to-load forwarding rule ignores access width. What should be checked?
Show answer and explanation
- Memory ranges and interpretation
- Pointer spelling alone
- The most recent store regardless of width
- Only source-text proximity
Answer: Memory ranges and interpretation
Partial or differently interpreted stores may not supply the entire loaded value.
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
- Yes; a shared start address defines all eight bytes.
- No; only half is established.
- Yes; the load automatically truncates itself to four bytes.
- No; forwarding is never valid for any load.
Answer: No; only half is established.
The supplied store covers only part of the load.
82.Two stores overlap by two bytes. What analysis matters?
Show answer and explanation
- Instruction count alone
- Only the source variable names
- Byte overlap and order
- Only access cost estimates
Answer: Byte overlap and order
Overlapping byte ranges can affect the later observed contents.
83.A pass simplifies a comparison using a range fact from a branch. What must hold?
Show answer and explanation
- The check occurred somewhere.
- Valid facts on all affected paths
- The value once had that range before reassignment.
- 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.A variable is assigned after a range check. What should happen to a stale range fact?
Show answer and explanation
- Retain the old range forever.
- Treat the assignment as semantically empty.
- Assume the new value inherits every prior bound.
- Invalidate stale facts.
Answer: Invalidate stale facts.
Dataflow facts depend on the actual definition and state.
85.A transformation duplicates a nondeterministic operation. What can change?
Show answer and explanation
- Only execution cost when each copy has the same opcode
- Only code size if the operation is individually valid
- No behavior because both operations return the same type
- Result relationships and effects
Answer: Result relationships and effects
One choice reused and multiple independent choices can differ semantically.
86.An optimizer assumes a library call's behavior from its name. What should be verified?
Show answer and explanation
- Spelling alone
- Recognized semantics and linkage
- Only the apparent argument count
- Only the return register
Answer: Recognized semantics and linkage
A symbol's name alone may not establish builtin semantics in every context.
87.An integer constant fold uses the compiler host's endianness for target memory bytes. What is needed?
Show answer and explanation
- Target layout
- Host layout alone
- Only the literal's source encoding
- Only the optimization level
Answer: Target layout
Cross-compilation must respect target interpretation.
88.A pass drops exception edges when merging blocks. What can be lost?
Show answer and explanation
- Only the normal successor's instruction count
- Only the ordinary return value
- No behavior if both blocks end in a branch
- Exception behavior
Answer: Exception behavior
Control-flow simplification must preserve permitted exception paths.
89.A pass moves cleanup after a return. What should validation examine?
Show answer and explanation
- Required cleanup execution
- Total instruction count alone
- Only textual source order
- 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.A pass preserves values but changes required synchronization. Is value equality alone sufficient?
Show answer and explanation
- Yes; final scalar equality covers every concurrent execution.
- Yes; synchronization is always a performance hint.
- No; this makes all optimization impossible.
- No; concurrency also matters.
Answer: No; concurrency also matters.
Concurrency can add behavioral requirements beyond one sequential result.
91.A transformation proof assumes an unreachable block is truly unreachable. What must support this?
Show answer and explanation
- Low profile frequency
- Sound unreachability evidence
- The block's lack of an ordinary predecessor, ignoring exceptional edges
- An unverified assertion from a prior transformation
Answer: Sound unreachability evidence
Unreachability requires more than rarity or intention.
92.An analysis deliberately overapproximates possible values. Why can that help correctness?
Show answer and explanation
- Preserving feasible behaviors
- It maximizes every optimization.
- It proves every listed value must occur.
- It removes the need for semantic assumptions.
Answer: Preserving feasible behaviors
Conservative analysis may lose precision while preserving safety for its use.
93.An analysis underapproximates aliases used to justify reordering. What risk arises?
Show answer and explanation
- Only missed opportunities
- An actual overlap may be treated as independent, causing wrong code.
- Guaranteed conservative independence
- 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.A legal optimization is skipped due to conservative analysis. What is the usual result?
Show answer and explanation
- Wrong behavior by definition
- An invalid source program
- A guaranteed compiler crash
- Lost optimization
Answer: Lost optimization
Conservatism can sacrifice profitability without violating semantics.
95.A solver proves equivalence under a restricted model. What should the claim disclose?
Show answer and explanation
- Assumptions and proof scope
- A guarantee for every target representation
- Only the number of solver queries
- Only agreement on sampled test inputs
Answer: Assumptions and proof scope
Formal evidence is limited by the semantics and assumptions encoded.
96.A proof omits floating exception flags required by the contract. What is the gap?
Show answer and explanation
- Only code size uncertainty
- A guarantee flags are irrelevant
- Missing observable behavior
- Proof that the missing effects cannot occur
Answer: Missing observable behavior
A proof must cover the behaviors the implementation must preserve.
97.A pass is nondeterministic because worklist order changes output. What should be distinguished?
Show answer and explanation
- Every output difference as a correctness bug
- Validity versus reproducibility
- Every nondeterministic output as harmless
- Only the file timestamp
Answer: Validity versus reproducibility
Multiple outputs can be valid, but semantic and reproducibility requirements need review.
98.An optimization bug occurs only after repeated pass execution. What should be checked?
Show answer and explanation
- Only the first successful run
- Preserved invariants
- Only the pass's textual name
- Only benchmark initialization
Answer: Preserved invariants
Repeated transforms can expose accumulating errors or invalid assumptions.
99.A candidate proposes a rewrite without stating preconditions. What should be requested?
Show answer and explanation
- Only an expected speedup
- A legality argument
- Only the shorter expression
- Only an assembly screenshot
Answer: A legality argument
Transformations need explicit assumptions and semantic reasoning.
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
- Both outputs are valid i8 values.
- At least one output is always zero.
- The original outputs were independent choices.
- 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.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
- Both pointers have the same element type.
- The read and write access ranges do not overlap.
- The load result has only one use.
- 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.