From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by sourceware.org (Postfix) with ESMTPS id 33C503858C33 for ; Mon, 22 Jan 2024 15:51:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 33C503858C33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 33C503858C33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d36 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705938719; cv=none; b=Hp6PUxCeSiqYOFirZ8iuhg+LdqLbuC++ss2K5nlmv273GAj1D7bRJP+VLPwJzW3rzoOZ/7Yx1vn2hbA6DdeJnZ7fRRdTFSBObjB2caF851yGff53Lqup/Chn7cAsq+NSH0HmS/ye2Z1uUB+dOldD9Mx6dVFB5dM0CJgbZqAFX4w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705938719; c=relaxed/simple; bh=kzuu2VrCo+pvvBMTnqgFxNty84m/yAs5srObrfm7AyQ=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=vp6WS6bzEOnxo7ydNAqTObF6hZKxYbhPbkIJ4jBAk3MZKjN4eIBOrEq0ANKnpXeHvKEqB/KvA5lipXt7N3yECjzXySc1jrNq8Gwt3f22shioOBgIMlAsQxqMOByJMv8wAys+fZOCyBYbO1FkU0BSwVJilwYfzlvK5479Qx0o0S4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd36.google.com with SMTP id ca18e2360f4ac-7beda6a274bso163692739f.2 for ; Mon, 22 Jan 2024 07:51:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705938717; x=1706543517; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=41narCvh0YrAkUWjOp2r4EsVrVF2SGnnnYKtYZKpNjI=; b=IMiTBwVQqmriEkJLAjcEaEQQxwStwx+NnbWTcuKQ1mD6pOIJ2LRHJwlugMemPoYXfR zkhmsIjZdWLGkB30YzWZy2oxEz1ua8VMUOd2zGRpPGQuuYwxJR5sUfzcji4Ngjp/D4Cb bA/1czYd1doje0w4E3wkPBZz9r4/gbBEBSrjnYYuRhL4GXIt6TDNVfNugtQ5EscG2qWG z1lnG5VEwE9jtQ6hWQMm53oG3VgcSuUildzag1vpT1rckLKhd1a1qahF0Bqg6sYA64e3 n89/wrengTDHUxGy79ea/p+uh9WxyPsQX+UDs1Xez+r5sFv/pjtmEbktGXNgKASL6a03 0lzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705938717; x=1706543517; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=41narCvh0YrAkUWjOp2r4EsVrVF2SGnnnYKtYZKpNjI=; b=gfQqALz/oznhM9yPX4MQtLgLPvYM3wdtR/YzCE9ByxNXxTugT2EmMu7gmk69Ej7E7/ riUrzbGV7pmkg3xrfjnC7gxpdBZS39BJ3ZCxWjdplBD5haE2S5jqhtm75Ru87u5dTT29 P+uE8EqOl5+7v64cNnG6knOXGAhoV1mDj2ozWTsUttDF4hi9aHPbEDcnZNfmE7/w+BKI 5KTL2X5tmsNznE4Qw7Y/IBKiUG6sfRIrxymmeEA6cmimknolK61z2iRvf+LQQq5LlK+e Ahz6aodafP6u7ei+bFsiQLzKGuV/dKqgrs0iql5f0RdcPl0w9IFddji9IbQDJRTfDs40 +M4Q== X-Gm-Message-State: AOJu0YwUtFU04/iiwDCbUtNzDtSKZ/+yLSwbpOVOEO3oYakV7xwtr/4W OJ0qhe2iseconQFlvUt9v3V3mA4Dhae8JAxqkcbpFnoj86CJIvGj X-Google-Smtp-Source: AGHT+IFDuMCNleEyUJ90PL5X7zNhbkwqY3MCXTU3qBwiSfKoZv8Cp0+N4mmyFjGsfg4QF2OuZBJbYg== X-Received: by 2002:a6b:c348:0:b0:7bf:4474:3753 with SMTP id t69-20020a6bc348000000b007bf44743753mr7714784iof.25.1705938717257; Mon, 22 Jan 2024 07:51:57 -0800 (PST) Received: from [172.31.0.109] ([136.36.72.243]) by smtp.gmail.com with ESMTPSA id w11-20020a056602034b00b007bf9eed92ebsm79419iou.26.2024.01.22.07.51.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Jan 2024 07:51:56 -0800 (PST) Message-ID: <1c9ed2d2-70b9-42c5-8a14-ffc074913d00@gmail.com> Date: Mon, 22 Jan 2024 08:51:55 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [middle-end PATCH] Prefer PLUS over IOR in RTL expansion of multi-word shifts/rotates. Content-Language: en-US To: Richard Biener , Georg-Johann Lay Cc: Roger Sayle , gcc-patches@gcc.gnu.org References: <023501da4a48$320e7540$962b5fc0$@nextmovesoftware.com> <71f8f116-e3b8-4e70-b30a-a4bc042466a2@gjlay.de> From: Jeff Law In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham 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 1/22/24 00:45, Richard Biener wrote: > On Fri, Jan 19, 2024 at 5:06 PM Georg-Johann Lay wrote: >> >> >> >> Am 18.01.24 um 20:54 schrieb Roger Sayle: >>> >>> This patch tweaks RTL expansion of multi-word shifts and rotates to use >>> PLUS rather than IOR for disjunctive operations. During expansion of >>> these operations, the middle-end creates RTL like (X<>C2) >>> where the constants C1 and C2 guarantee that bits don't overlap. >>> Hence the IOR can be performed by any any_or_plus operation, such as >>> IOR, XOR or PLUS; for word-size operations where carry chains aren't >>> an issue these should all be equally fast (single-cycle) instructions. >>> The benefit of this change is that targets with shift-and-add insns, >>> like x86's lea, can benefit from the LSHIFT-ADD form. >>> >>> An example of a backend that benefits is ARC, which is demonstrated >>> by these two simple functions: >> >> But there are also back-ends where this is bad. >> >> The reason is that with ORI, the back-end needs only to operate no >> these sub-words where the sub-mask is non-zero. But for PLUS this >> is not the case because the back-end does not know that intermediate >> carry will be zero. Hence, with PLUS, more instructions are needed. >> An example is AVR, but maybe much more target with multi-word operations >> are affected in a bad way. >> >> Take for example the case with 2 words and a value of 1. >> >> LO |= 1 >> HI |= 0 >> >> can be optimized to >> >> LO |= 1 >> >> but for addition this is not the case: >> >> LO += 1 >> HI +=c 0 ;; Does not know that always carry = 0. > > I wonder if the PLUS can be done on the lowpart only to make this > detail obvious? In theory, yes. This class of problems has often been punted to the target expanders (far from ideal). I still suspect the way forward here is to have the exp* code query one or more target properties to guide IOR vs PLUS selection. Jeff