Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp5633484rwi; Tue, 18 Oct 2022 01:46:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM66GeSh+bDT4xBDxoU298mZJTgV7i+TM9+pKdCysSwcOoFcaiObUVVMKAiX+12QXZ2C8u0N X-Received: by 2002:a05:6402:2949:b0:451:fabf:d88a with SMTP id ed9-20020a056402294900b00451fabfd88amr1596486edb.324.1666082762433; Tue, 18 Oct 2022 01:46:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666082762; cv=none; d=google.com; s=arc-20160816; b=kuLemtBiPkbKnEaluFdCDnK1WrTzrtLw8w1eLTJ6pxExqT3qXzDfIauPJFMo65Fu/o L1nXKgFVJCk6btSVjQNOaGj/H2HPJZGkqWRstrL1+MpHEajnq7Re+A5f9loGIm8wYURq GJl6/uXC2ZF9nJoIgYiIy7C2neCumnlBRnZimKUqe5THACQ0JAp9TJJrCwPFqwlMn+7F JKK8E+LA8+JAfwpU5OhovVbMGcZi44JancZv2nd2e3y4UmZWNmU6QAWgpC/MsHAd9doJ RwikZLQBx/lUL1ylg5cc1k/u60xe3jkKhTISgwtkgp2wItT/t443oZ7FfNNkttcP2ygN J5bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=DcgHZhWC87diD08vaBxk1XV0rJ4hbnTtCkS1CpNBq1c=; b=oNJ3ZODW1VjIB3PJLdRu5TUofGer0lnjB5XyUzteLA5G4iGMZ7NinbSdvsDHwSEZsH BSzPuzt+z56ffuX0rBFef84oSTYkHJP/5nCjLW/lbIaxFvF1MTt5SwB3fb7/cFf43uB9 pJOyCPRjIBlZN0Bd2x3LY+zw0nQu0zjPR3Zg7wx7FrDbrXPWrk4ba54lCG7v6CHH6NQN n0/GLTkLQiYDbO8KXfrvjJAWJPWlBA7hz4xISehVBhiY5t4OdNfqxl6/ua43h3ScwyqD 2G2c1Cuc2nUs76/L6ah4eQkzFk4LuX//p0s56GbZNqzERMU6zQEoPkLnV5k9Ze4IRNlR wFhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=Oe6D8dWN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g8-20020a056402320800b0045ccd1715d5si11128365eda.435.2022.10.18.01.45.35; Tue, 18 Oct 2022 01:46:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=Oe6D8dWN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230102AbiJRIJf (ORCPT + 99 others); Tue, 18 Oct 2022 04:09:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229550AbiJRIJd (ORCPT ); Tue, 18 Oct 2022 04:09:33 -0400 Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4675A11813 for ; Tue, 18 Oct 2022 01:09:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1666080568; bh=qdvFsQ/lCWl0sUbt75T+DP3VwTt8nZuoicBEZ3m6IBc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Oe6D8dWNwzZes1JZTzieYLLrmx6jyC1gICh0elTn+Kupq1hl47is6BnlOHPbgm5cF HOUI+baX1le6HsjVaydsvI/o3xo6piPMlIU5qA5QIQzI4phNQzu+ThqsWUUPuJmVeg t02b5hRgBP59KvDv6COVMYVGOwQmm1lW97hvdQk8= Received: from [100.100.57.122] (unknown [220.248.53.61]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id D4856600A9; Tue, 18 Oct 2022 16:09:27 +0800 (CST) Message-ID: Date: Tue, 18 Oct 2022 16:09:27 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:107.0) Gecko/20100101 Thunderbird/107.0a1 Subject: Re: [PATCH V2] LoongArch: Add unaligned access support Content-Language: en-US To: David Laight , 'Huacai Chen' Cc: Huacai Chen , "loongarch@lists.linux.dev" , Xuefeng Li , Tiezhu Yang , Guo Ren , Jiaxun Yang , "linux-kernel@vger.kernel.org" References: <20221017022330.2383060-1-chenhuacai@loongson.cn> From: WANG Xuerui In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/10/18 15:48, David Laight wrote: > From: Huacai Chen >> Sent: 18 October 2022 08:33 > ... >>> What about my more structured approach in another reply that avoids the >>> huge else-if conditions? Both the terrible line wraps and codegen could >>> be avoided. > ... >> OK, let me try. > > I suspect you can mask out some 'operand size' bits from the > instructions - instead of checking each opcode. Technically LoongArch instruction formats don't contain any "operand size bit", because most current opcodes seem to be simply sequentially allocated. While there seem to exist a certain pattern in e.g. encodings of {LD,ST,FLD,FST}.{B,H,W,D}, I believe it's just coincidence (e.g. bits 23:22 of those instructions seem to represent "B/H/W/D"; but other instructions clearly don't follow such a pattern, not even the {LD,ST}.{BU,HU,WU} ones). For now I'd personally prefer readability and maintainability over performance, because traps are already expensive enough that optimizations like this don't really matter. -- WANG "xen0n" Xuerui Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/