From: Igor Munkin via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Sergey Kaplun <skaplun@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH luajit] IR_MIN/IR_MAX is non-commutative due to underlying FPU ops. Date: Thu, 23 Nov 2023 06:30:49 +0000 [thread overview] Message-ID: <ZV7xmbvRJCjMniqr@tarantool.org> (raw) In-Reply-To: <20231024101420.12398-1-skaplun@tarantool.org> Sergey, I've checked the patchset into all long-term branches in tarantool/luajit and bumped a new version in master, release/2.11 and release/2.10. On 24.10.23, Sergey Kaplun via Tarantool-patches wrote: > From: Mike Pall <mike> > > Thanks to Peter Cawley. > > (cherry-picked from commit 7a2b83a0c5d980bf3db0aeda33c79e7bb4b3da01) > > Even after the commit c05d103305da0626e025dbf81370ca9f4f788c83 ("Fix > math.min()/math.max() inconsistencies."), some of the corner cases (see > tests in the commit for details) for `math.min()`/`math.max()` still > inconsistent in the JIT and the VM. This happens because `IR_MIN` and > `IR_MAX` are marked as commutative, so their operands were swapped by > `asm_swapops()`. As a result, because `minsd`[1]/`maxsd`[2] instructions > don't change the sign byte of the destination register, its sign is > preserved if we compare 0 with -0. When we compare something with NaN, > the second source operand (either a NaN or a valid floating-point value) > is written to the result. Hence, swapping the operands changed the > resulting value. > > This patch removes the commutative flag from the aforementioned IRs to > prevent swapping of their operands. > > [1]: https://c9x.me/x86/html/file_module_x86_id_173.html > [2]: https://c9x.me/x86/html/file_module_x86_id_168.html > > Sergey Kaplun: > * added the description and the test for the problem > > Part of tarantool/tarantool#9145 > --- > > Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-1082-min-max-0-commutative > Tarantool PR: https://github.com/tarantool/tarantool/pull/9294 > Related Issues: > * https://github.com/tarantool/tarantool/issues/9145 > * https://github.com/LuaJIT/LuaJIT/issues/1082 > * https://github.com/LuaJIT/LuaJIT/issues/957 > > src/lj_ir.h | 4 +- > test/tarantool-tests/gh-6163-min-max.test.lua | 23 ++++------- > .../lj-1082-min-max-0-commutative.test.lua | 41 +++++++++++++++++++ > 3 files changed, 51 insertions(+), 17 deletions(-) > create mode 100644 test/tarantool-tests/lj-1082-min-max-0-commutative.test.lua > <snipped> > -- > 2.42.0 > -- Best regards, IM
prev parent reply other threads:[~2023-11-23 6:36 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-10-24 10:14 Sergey Kaplun via Tarantool-patches 2023-10-24 11:35 ` Maxim Kokryashkin via Tarantool-patches 2023-11-10 11:18 ` Sergey Bronnikov via Tarantool-patches 2023-11-23 6:30 ` Igor Munkin via Tarantool-patches [this message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=ZV7xmbvRJCjMniqr@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=imun@tarantool.org \ --cc=skaplun@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH luajit] IR_MIN/IR_MAX is non-commutative due to underlying FPU ops.' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox