From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 4B9CE68A492; Tue, 3 Oct 2023 19:24:06 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4B9CE68A492 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1696350246; bh=b6iKnQAAZNoveIqYoPZyKmSO4ZMyRFFRAaGuWndSGUI=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=VaS7S4uglULEW9uF3mjZjStd/XkBC70GlCpujmlPgkLQxevcKVyBrkuYVZwy+L83z lVF5yufv6v2SiQ9b9zkBwD2a2esq5vYD4amw/t2fOcqa+DJdDt5ky3yEAGFaYiaGED CWgeRTLlyqAbQ0i6CeLlr8Slt7La1r5F2QplE/7E= Received: from smtpng3.i.mail.ru (smtpng3.i.mail.ru [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id E509C68A492 for ; Tue, 3 Oct 2023 19:24:04 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E509C68A492 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1qniBo-0007A1-2p; Tue, 03 Oct 2023 19:24:04 +0300 Message-ID: Date: Tue, 3 Oct 2023 19:24:03 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Content-Language: en-US To: Maksim Kokryashkin , tarantool-patches@dev.tarantool.org, skaplun@tarantool.org, m.kokryashkin@tarantool.org References: <20231003133705.5700-1-max.kokryashkin@gmail.com> In-Reply-To: <20231003133705.5700-1-max.kokryashkin@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD905284D235AF2CB535FFCE1AE18EEFCAAC554EE2F59A1CEEA182A05F5380850404C228DA9ACA6FE27915E1F15FA34C9EF9D189F7D9A080283D8A8BAC8F82D57D4CFA34654DA964149 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7353CFE866E745C13EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006374A24022C550661178638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8AC375BD44C312C8A395D985A34150382117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCECADA55FE5B58BB7A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18BDFBBEFFF4125B51D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6ACE00135B021D8CA089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A5F3226E029613CA60E5F32F9953FF2420897F5DAB0EDFE483F87CCE6106E1FC07E67D4AC08A07B9B0B355ED1E20F5346ACB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF33FA05F2E48C7D3C7D26B5533700E6CB6546B0BC0771BB68771C29D9C6B8D2DDC7C5EACBE3BE5B47CC231B5D63B17C6B7BF380F69254129EAFDCE99B338CFB83A74DFFEFA5DC0E7F02C26D483E81D6BE0DBAE6F56676BC7117BB6831D7356A2DEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojH0UbTrDsBkB4CRcwITLbbA== X-DA7885C5: BF0E20C94DD4D213E49EA9F554F33F5460A4F40AB74AA7E6AAE33A8FAC959EDB262E2D401490A4A0DB037EFA58388B346E8BC1A9835FDE71 X-Mailru-Sender: 689FA8AB762F73930F533AC2B33E986B1E65405B3A6973286C4ABE7C2D8B08D2DD788429FD8613638ED9BB8B05EE7B3AFB559BB5D741EB96D19CD4E7312BAA970A04DAD6CC59E3365FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit v2] Mark CONV as non-weak, to prevent elimination of its side-effect. X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Max thanks for the patch! On 10/3/23 16:37, Maksim Kokryashkin wrote: > --- /dev/null > +++ b/test/tarantool-tests/mark-conv-non-weak.test.lua > @@ -0,0 +1,115 @@ > +local tap = require('tap') > +local test = tap.test('mark-conv-non-weak'):skipcond({ > + ['Test requires JIT enabled'] = not jit.status(), > +}) > + > +test:plan(1) > + > +local data = {0.1, 0, 0.1, 0, 0 / 0} Is it possible to reduce a number of elements in the table? I would add a comment where describe why exactly these magic values were chosen. > +local sum = 0 > + > +jit.opt.start('hotloop=2', 'hotexit=2') Why values are equal to 2 and not 1, that we usually set in tests? > + > +-- XXX: The test fails before the patch only > +-- for `DUALNUM` mode. All of the IRs below are > +-- produced by the corresponding LuaJIT build. > + > +-- When the trace is recorded, the IR > +-- is the following before the patch: > +---- TRACE 1 IR > +-- .... SNAP #0 [ ---- ---- ---- ---- ---- ---- ---- ---- ---- ] > +-- 0001 u8 XLOAD [0x100dac521] V > +-- 0002 int BAND 0001 +12 > +-- 0003 > int EQ 0002 +0 > +-- 0004 > int SLOAD #8 T > +-- .... SNAP #1 [ ---- ---- ---- ---- ---- ---- ---- ---- ---- ] > +-- 0005 > num SLOAD #3 T > +-- 0006 num CONV 0004 num.int > +-- 0007 + num ADD 0006 0005 > +-- 0008 > fun SLOAD #4 T > +-- 0009 > tab SLOAD #5 T > +-- 0010 > int SLOAD #6 T > +-- 0011 > fun EQ 0008 ipairs_aux > +-- 0012 + int ADD 0010 +1 > +-- 0013 int FLOAD 0009 tab.asize > +-- 0014 > int ABC 0013 0012 > +-- 0015 p64 FLOAD 0009 tab.array > +-- 0016 p64 AREF 0015 0012 > +-- 0017 >+ num ALOAD 0016 > +-- .... SNAP #2 [ ---- ---- ---- 0007 ---- ---- 0012 0012 0017 ] > +-- 0018 ------ LOOP ------------ > +-- 0019 u8 XLOAD [0x100dac521] V > +-- 0020 int BAND 0019 +12 > +-- 0021 > int EQ 0020 +0 > +-- 0022 > int CONV 0017 int.num > +-- .... SNAP #3 [ ---- ---- ---- 0007 ---- ---- 0012 0012 0017 ] > +-- 0023 + num ADD 0017 0007 > +-- 0024 + int ADD 0012 +1 > +-- 0025 > int ABC 0013 0024 > +-- 0026 p64 AREF 0015 0024 > +-- 0027 >+ num ALOAD 0026 > +-- 0028 num PHI 0017 0027 > +-- 0029 num PHI 0007 0023 > +-- 0030 int PHI 0012 0024 > +---- TRACE 1 stop -> loop > + > +---- TRACE 1 exit 0 > +---- TRACE 1 exit 3 > +-- > +-- And the following after the patch: > +---- TRACE 1 IR > +-- .... SNAP #0 [ ---- ---- ---- ---- ---- ---- ---- ---- ---- ] > +-- 0001 u8 XLOAD [0x102438521] V > +-- 0002 int BAND 0001 +12 > +-- 0003 > int EQ 0002 +0 > +-- 0004 > int SLOAD #8 T > +-- .... SNAP #1 [ ---- ---- ---- ---- ---- ---- ---- ---- ---- ] > +-- 0005 > num SLOAD #3 T > +-- 0006 num CONV 0004 num.int > +-- 0007 + num ADD 0006 0005 > +-- 0008 > fun SLOAD #4 T > +-- 0009 > tab SLOAD #5 T > +-- 0010 > int SLOAD #6 T > +-- 0011 > fun EQ 0008 ipairs_aux > +-- 0012 + int ADD 0010 +1 > +-- 0013 int FLOAD 0009 tab.asize > +-- 0014 > int ABC 0013 0012 > +-- 0015 p64 FLOAD 0009 tab.array > +-- 0016 p64 AREF 0015 0012 > +-- 0017 >+ num ALOAD 0016 > +-- .... SNAP #2 [ ---- ---- ---- 0007 ---- ---- 0012 0012 0017 ] > +-- 0018 ------ LOOP ------------ > +-- 0019 u8 XLOAD [0x102438521] V > +-- 0020 int BAND 0019 +12 > +-- 0021 > int EQ 0020 +0 > +-- 0022 > int CONV 0017 int.num > +-- .... SNAP #3 [ ---- ---- ---- 0007 ---- ---- 0012 0012 0017 ] > +-- 0023 + num ADD 0017 0007 > +-- 0024 + int ADD 0012 +1 > +-- 0025 > int ABC 0013 0024 > +-- 0026 p64 AREF 0015 0024 > +-- 0027 >+ num ALOAD 0026 > +-- 0028 num PHI 0017 0027 > +-- 0029 num PHI 0007 0023 > +-- 0030 int PHI 0012 0024 > +---- TRACE 1 stop -> loop > + > +---- TRACE 1 exit 0 > +---- TRACE 1 exit 2 > +-- > +-- Before the patch, the `0022 > int CONV 0017 int.num` I see that IR "0022 > int CONV ..." is present in both IR traces... > +-- instruction is omitted due to DCE, which results in the > +-- third side exit being taken, instead of the second, > +-- and, hence, incorrect summation. After the patch, `CONV` > +-- is left intact and is not omitted; it remains as a guarded > +-- instruction, so the second side exit is taken and sum is > +-- performed correctly. > + > +for _, val in ipairs(data) do > + if val == val then > + sum = sum + val > + end > +end > + > +test:ok(sum == sum, 'NaN check was not omitted') > +test:done(true) > -- > 2.39.3 (Apple Git-145) >