From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from xry111.site (xry111.site [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id 6F1F23858C33 for ; Wed, 31 Jul 2024 10:25:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6F1F23858C33 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xry111.site ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6F1F23858C33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=89.208.246.23 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722421512; cv=none; b=DS39DgeYGHwqAVfsYajav4y+1eIi0UZfMmI9KpdvATWNf85Mo5BVHZZIPHiML+cCO2BsQ1T4JYxNrgtUIfNQb+MzctBZM3AlJnvVu753JMB55SQm9DJEHYd94MAnwuuoVFxb4ptqCxwoj+b34eR2ckRDJpUiggak/Nunr7GXYZ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722421512; c=relaxed/simple; bh=JUfnb61RMqEenKMvCV3hRRyKK+oBR7H+nRTWfnsHXsQ=; h=DKIM-Signature:Message-ID:Subject:From:To:Date:MIME-Version; b=kirFsKrFKG8R2eIaEboHmdTUW3gq0vchG0tSLd1+sSolCPOADB+y418LtEibN2mcHMaN2htRx0sMSkkbWn2XXZaq3zXSY6wFiXyjqsIjN4y/iB5Nptdek/aqUjMice6VnLkDNfymTUfgXaG+AiHOdFfgA3iwD3Tm+5zwYGnEoYQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1722421509; bh=JUfnb61RMqEenKMvCV3hRRyKK+oBR7H+nRTWfnsHXsQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=XQAVuaBEdU1Eu7uFHA+4Df6+gnfKwe7lcUvQ1J6wt4mLGjW2ahxYi4w6TUXiQStl3 YcO0Hp88Evc7YHy3KhErHzD0p1Wv7jPI/RNRnGNmsi7OaXdLbh7TxOGb/jRHXFefXA zOq3BsNFEeD4bGRMlhotOHO4VnCRDwPtU1uNrRAs= Received: from [192.168.124.6] (unknown [113.200.174.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 082A06709F; Wed, 31 Jul 2024 06:25:07 -0400 (EDT) Message-ID: Subject: Re: [PATCH] LoongArch: Rework bswap{hi,si,di}2 definition From: Xi Ruoyao To: Lulu Cheng , gcc-patches@gcc.gnu.org Cc: i@xen0n.name, xuchenghua@loongson.cn Date: Wed, 31 Jul 2024 18:25:04 +0800 In-Reply-To: References: <20240729075837.6060-1-xry111@xry111.site> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.52.3 MIME-Version: 1.0 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,LIKELY_SPAM_FROM,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, 2024-07-31 at 16:57 +0800, Lulu Cheng wrote: >=20 > =E5=9C=A8 2024/7/29 =E4=B8=8B=E5=8D=883:58, Xi Ruoyao =E5=86=99=E9=81=93: > > Per a gcc-help thread we are generating sub-optimal code for > > __builtin_bswap{32,64}.=C2=A0 To fix it: > >=20 > > - Use a single revb.d instruction for bswapdi2. > > - Use a single revb.2w instruction for bswapsi2 for TARGET_64BIT, > > =C2=A0=C2=A0=C2=A0 revb.2h + rotri.w for !TARGET_64BIT. > > - Use a single revb.2h instruction for bswapsi2 (x) r>> 16, and a singl= e > > =C2=A0=C2=A0=C2=A0 revb.2w instruction for bswapdi2 (x) r>> 32. > >=20 > > Unfortunately I cannot figure out a way to make the compiler generate > > revb.4h or revh.{2w,d} instructions. >=20 > This optimization is really ingenious and I have no problem. >=20 > I also haven't figured out how to generate revb.4h or revh. {2w,d}. > I think we can merge this patch first. Pushed r15-2433. FWIW I tried a naive pattern for revh.2w: (set (match_operand:DI 0 "register_operand" "=3Dr") (ior:DI (and:DI (ashift:DI (match_operand:DI 1 "register_operand" "r") (const_int 16)) (const_int 18446462603027742720)) (and:DI (lshiftrt:DI (match_dup 1) (const_int 16)) (const_int 281470681808895)))) But it seems too complex to be recognized. --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University