Repository navigation
Fix the x 1 idiv and x -1 exp simplifications in PSStackToTree - #22438
Conversation
`x 1 idiv` was simplified to `x`, so the Wasm and JS compilers returned a non-integer x unchanged (e.g. 7.5), whereas the interpreter truncates it (7). It's now simplified to `truncate(x)`. `x -1 exp` was rewritten as `1 x div`, which gives 0 for x = 0 since a division by zero returns 0, whereas the interpreter computes Infinity, which is then clipped to the range. This rewrite is removed.
Viewer preview🗑️ Viewer previews removed. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #22438 +/- ##
=======================================
Coverage 90.52% 90.53%
=======================================
Files 276 276
Lines 68551 68549 -2
=======================================
Hits 62059 62059
+ Misses 6492 6490 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merging this PR will improve performance by 11.73%
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
Two algebraic simplifications in
PSStackToTreechange the result, so the Wasm and JS compilers disagree with the interpreter:x 1 idivwas simplified tox. With a non-integer input,{ 1 idiv }returned 7.5 from the compilers and 7 from the interpreter. It's now simplified totruncate(x).x -1 expwas rewritten as1 x div. For x = 0 that gives 0, since a division by zero returns 0, whereasexpgives Infinity, which is then clipped to the range. The rewrite is removed.The existing tests only used integer inputs or asserted the old tree shape, so they're updated, and new cases run both operators with the inputs above.