[Tarantool-patches] [PATCH luajit] Fix FOLD rule for strength reduction of widening.
imun at tarantool.org
Thu Jun 30 15:09:55 MSK 2022
I've checked the patch into all long-term branches in tarantool/luajit
and bumped a new version in master, 2.10 and 1.10.
On 18.10.21, Sergey Kaplun wrote:
> From: Mike Pall <mike>
> Reported by Matthew Burk.
> (cherry picked from commit 9f0caad0e43f97a4613850b3874b851cb1bc301d)
> The simplify_conv_sext optimization is used for reduction of widening.
> cdata indexing narrow optimization uses it for narrowing of a C array
> index. The optimization eliminates sign extension for corresponding
> integer value. However, this conversion cannot be omitted for non
> constant values (for example loading stack slots) as far as their sign
> extension may change. The emitted machine code may be incorrect without
> aforementioned conversion (for example mov instruction instead movsxd is
> used on x86 architecture). As a result the value in a destination
> register during trace execution is invalid.
> This patch allows this optimization only for constant integer values.
> Sergey Kaplun:
> * added the description and the test for the problem
> Tarantool branch: https://github.com/tarantool/tarantool/tree/skaplun/gh-noticket-fix-fold-simplify-conv-sext
> Branch: https://github.com/tarantool/luajit/tree/skaplun/gh-noticket-fix-fold-simplify-conv-sext
> src/lj_opt_fold.c | 2 +-
> .../lj-fix-fold-simplify-conv-sext.test.lua | 35 +++++++++++++++++++
> 2 files changed, 36 insertions(+), 1 deletion(-)
> create mode 100644 test/tarantool-tests/lj-fix-fold-simplify-conv-sext.test.lua
More information about the Tarantool-patches