Repository navigation
Evaluate assignment targets once in both models - #679
perfloop-agent wants to merge 25 commits into
Conversation
|
@perfloop-agent fix merge conflicts |
|
This change is way too disruptive. It introduces a lot of churn for code without side effects. |
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
|
The churn comes from applying the target-binding block even when neither operand has side effects. I propose keeping the existing lowering for those cases, adding the missing result for unsigned/promoted value assignments, and reserving the binding for effectful operands. Broken value expressions would still need different output; how does that sound? |
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Yes, change the output only when needed (i.e., when there are side effects). |
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
f483ee5 to
1cbc95b
Compare
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
|
The update left the existing |
Unsigned and promoted compound assignments can update the wrong element when the target has side effects. Using their result can also produce Rust with unit type instead of the assigned value, while value-used simple assignments can evaluate the target again. Both models now keep the selected target for the store and result when needed.
For an array starting with
{10, 20, 30, 40}andi = 0,a[i++] += 5previously read the first element but stored15in the second, leavingi = 2. The translation now updates the first element and leavesi = 1, as native C++ does.For independent selectors, output changes only when the target or right operand has a side effect, or when a value-used unsigned or promoted compound produced
(). Value-used assignments also keep the binding when the store can change the index, as iny = (a[a[0]] += 1).Cost check on
entries[0].value += delta(i)(global array, call on the right), refcount model, ten calls of 100,000 updates: elapsed medians 2.193 ms on the base and 1.749 ms with this change, 21.0% faster across 28 pairs. The new form borrows the global once per update instead of twice.The compact regression in
tests/unit/assignment_single_eval.cppcovers the value, sequencing and target-selection cases, including references and pointers returned by a temporary owner. Those owners now stay alive through the full expression. All pre-existing expected outputs remain unchanged.Testing: the scoped Debug and Release lit runs each report 51 passed and one expected failure, comparing native C++ with both models.
Cost-check figures
Elapsed time: Base median 2,193,203 ns; This change median 1,749,155 ns. Paired median change −460,423 ns, with sequential bounds −644,933 to −251,058 ns from 28 complete pairs.
Case and evidence
Made by Perfloop. Human sponsor: Tomás Senart.