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 276D24CC570; Wed, 28 Jun 2023 14:02:07 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 276D24CC570 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1687950127; bh=V+FIp+/B0KoNlFGZafCvqod/w2RKWYRAxnSmrY283no=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=gpe0/tv2E/77lC5WM8xCI8jgo/zbyrioRUlJPtd2rgZ8gkVp5dhynX3hIW+dOUB/8 F4IbCCMSwa7aqMpYYgHLCnbh91Dn80d/+6XieQ2KwAo4q6NU2VzvMeps4k2TQRdnRp 9qDBDNDF+9PwXRLu/i86Q2axmsh0Ps10VISj80mo= Received: from smtp44.i.mail.ru (smtp44.i.mail.ru [95.163.41.82]) (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 C88E14CC570 for ; Wed, 28 Jun 2023 14:02:05 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C88E14CC570 Received: by smtp44.i.mail.ru with esmtpa (envelope-from ) id 1qESw1-006R18-1X; Wed, 28 Jun 2023 14:02:05 +0300 Date: Wed, 28 Jun 2023 13:57:48 +0300 To: Maxim Kokryashkin Message-ID: References: <20230613124237.2520-1-m.kokryashkin@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230613124237.2520-1-m.kokryashkin@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD95D99986233CC4DDCD825FF3AA070ECA39738A637400F637F182A05F5380850401770343D7E91355F2F85BE28C6F2E64EBD34BE276ED8A744B7B1ECE26990D759 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE771540F9ECFC94C4BEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637790A9327A9AFEF4F8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8B212DEC8547FCA8422A3389692017ECB117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F4460429728776938767073520437C869540D2AB0F28451B159A507268D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE042285CD7A5C321F4DC33E588678F033D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE3F8BD4E506CFA3D88C0837EA9F3D19764C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947C1D471462564A2E192E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89F83C798A30B85E16B156CCFE7AF13BCA4B5C8C57E37DE458BEDA766A37F9254B7 X-C1DE0DAB: 0D63561A33F958A5075676F3BB6959F79649CAF5141988B858D8DE786FBC178DF87CCE6106E1FC07E67D4AC08A07B9B06A1CB4668A9CA5FACB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CFF8FBE9F0A3922E0F190097003E60B0DBD4D671CD3FBC9D900CDC58C20B8FAA5D5B8C288B04B80C1C00E7A357E10733740BAAF4A267ED54EC6A58B379F7DF634EE48CAC7CA610320002C26D483E81D6BE5EF9655DD6DEA7D65774BB76CC95456EEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj1ET+iAiNOryGrybig8bxwg== X-Mailru-Sender: 11C2EC085EDE56FAC07928AF2646A769E5E58B27B5AAF9262F85BE28C6F2E64E8FF8BC079CCEBBDCDEDBA653FF35249392D99EB8CC7091A70E183A470755BFD208F19895AA18418972D6B4FCE48DF648AE208404248635DF X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit v2] x64: Fix 64 bit shift code generation. 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 Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Maxim! Thanks for the fixes! LGTM, with an ignorable nit below. Also, I suppose it is better to rebase on the newest master (since merged C tests may conflict with your changes). On 13.06.23, Maxim Kokryashkin wrote: > From: Mike Pall > > Reported by Philipp Kutin. > Fix contributed by Peter Cawley. > > (cherry-picked from commit 03a7ebca4f6819658cdaa12ba3af54a17b8035e9) > > Branch: https://github.com/tarantool/luajit/tree/fckxorg/fix-bit-shift-generation > PR: https://github.com/tarantool/tarantool/pull/8727 > > src/lj_asm_x86.h | 2 +- > test/tarantool-tests/CMakeLists.txt | 1 + > .../fix-bit-shift-generation.test.lua | 48 +++++++++++++++++++ > .../fix-bit-shift-generation/CMakeLists.txt | 1 + > .../libtestbitshift.c | 8 ++++ > 5 files changed, 59 insertions(+), 1 deletion(-) > create mode 100644 test/tarantool-tests/fix-bit-shift-generation.test.lua > create mode 100644 test/tarantool-tests/fix-bit-shift-generation/CMakeLists.txt > create mode 100644 test/tarantool-tests/fix-bit-shift-generation/libtestbitshift.c > > diff --git a/src/lj_asm_x86.h b/src/lj_asm_x86.h > index e6c42c6d..63d332ca 100644 > --- a/src/lj_asm_x86.h > +++ b/src/lj_asm_x86.h > diff --git a/test/tarantool-tests/CMakeLists.txt b/test/tarantool-tests/CMakeLists.txt > index a428d009..d36271f1 100644 > --- a/test/tarantool-tests/CMakeLists.txt > +++ b/test/tarantool-tests/CMakeLists.txt > diff --git a/test/tarantool-tests/fix-bit-shift-generation.test.lua b/test/tarantool-tests/fix-bit-shift-generation.test.lua > new file mode 100644 > index 00000000..e3f30eae > --- /dev/null > +++ b/test/tarantool-tests/fix-bit-shift-generation.test.lua > +local testbitshift = ffi.load('testbitshift') > +ffi.cdef[[ > +uint64_t > +testbitshift > +(const int arg1, const int arg2, const int arg3, const uint64_t arg4) Side note: See the ignorable comment for the testbitshift lib below. > +]] > + > +local result = {} > +jit.opt.start('hotloop=1') > + > +for i = 1, NTESTS do > + -- The rotation is performed beyond the 32-bit size, for > + -- truncation to become noticeable. `testbitshift` is used to > + -- ensure that the result of rotation goes into the `rcx`, > + -- corresponding to the x86_64 ABI. Although it is possible to > + -- use a function from the C standard library for that, all of > + -- the suitable ones are variadic, and variadics are recorded > + -- incorrectly on Apple Silicon. Side note: still think that we also should fix the M1 behaviour (but in the different patch set, obviously). And we shouldn't forget to update this test after, I believe. > + result[i] = testbitshift.testbitshift(1, 1, 1, rol(1ULL, i + 32)) > diff --git a/test/tarantool-tests/fix-bit-shift-generation/CMakeLists.txt b/test/tarantool-tests/fix-bit-shift-generation/CMakeLists.txt > new file mode 100644 > index 00000000..f85f875b > --- /dev/null > +++ b/test/tarantool-tests/fix-bit-shift-generation/CMakeLists.txt > diff --git a/test/tarantool-tests/fix-bit-shift-generation/libtestbitshift.c b/test/tarantool-tests/fix-bit-shift-generation/libtestbitshift.c > new file mode 100644 > index 00000000..0785ebba > --- /dev/null > +++ b/test/tarantool-tests/fix-bit-shift-generation/libtestbitshift.c > @@ -0,0 +1,8 @@ > +#include > + > +uint64_t > +testbitshift > +(const int arg1, const int arg2, const int arg3, const uint64_t arg4) > +{ > + return arg4; > +} I suggest to use more meaningful naming (like we need to get only 4th argument of the function). Also, it helps with linewidth. | uint64_t | pick4(const int arg1, const int arg2, const int arg3, const uint64_t res) | { | return res; | } Feel free to ignore. But if you prefer the new naming -- don't forget to change it in the Lua test too. Also, it is strange that the compiler doesn't warn about unused arguments, but OK. > -- > 2.40.1 > -- Best regards, Sergey Kaplun