From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by sourceware.org (Postfix) with ESMTPS id EFF043858296 for ; Tue, 9 Jan 2024 09:25:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EFF043858296 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 EFF043858296 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::531 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704792356; cv=none; b=SWJ7TgGt/z5FzSzZkXlQyeZoB5Tay9NHm8AOgLPkKIW+XTXV4RGXlW9YyrKep4+1ivNbbuvgFTfH9Qap3ErbIVMXSS0b5gTG3H8hqfp/WsAtBB1OxUw9fH9VNPjrgU2AjjHnEhfTGzv5O/MzTYtlDVeEf82aCHRZBc6eTMjLVJ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704792356; c=relaxed/simple; bh=WlOhCin/A0995TlsJ6gyUEMQlxyR1d2R6DM6DTeD6cM=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=eHJpFiazAIZxb+9JDv04lwmPnT+qGKsDxOIpycBzzGris+Ani9fyp00Ri8ks0rXMwSBeAPp0/DFRC0NkSHZWjXSAqkiXP8DpIal1ztzEXp58Uai//K7Ik3lAO/nZAYNX4KZbLg3GYede2rFdvFROgX5j9D07B0XbRyzNA1AtzUA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-5576fae29ffso2621368a12.1 for ; Tue, 09 Jan 2024 01:25:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704792352; x=1705397152; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Po3Cg0m6Hqpo4QghvN9QmWopCbfqykvV+0B/wqso/W0=; b=huelkldekOaAVUZNGn4+HDUD53MIVD723CJKrwh9aPoYcee9bwNK2dxG7QiQucLJg8 Gu4EMr4yClBo9De56Fqb4Khk5LYG9mNFNEn5ZhHk5iGdYCyF9/C1EpbY/pvVcdxRLAwD G4FwVMIuO2kfG8HVITr4z8rSH+uDxCBhYfggMIJshDJmukhjiT0f/jS+NdH3bYwrkDDM zXvImA8LZVbpuKRZP7BvpA784zndhxmSVsL23KxmRzUEBdyZW8ZaZRnWaTWAajsQJMNP SiwgVKgqVIWxjzOPQYobu62X16Xbf3q0Eb8usi0G9ss/OxN6XE6FB0U/DZPZF9Eauzzo Q0gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704792352; x=1705397152; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Po3Cg0m6Hqpo4QghvN9QmWopCbfqykvV+0B/wqso/W0=; b=g+Ajkt+FgeZSYsrnO+DdGJX7EFR5lnXBFGB0aZ6kYeoIZ547E6wyxTKLzaap/gobi3 asGTKKim3mXwkjKakJthgsAtlKreE5D0ZGjSKQEE785PnFxNCtDRkatrOBmaSCensy2Z iv+PyWRqwqr0OLhUoEJ+h9OR4UqbPyw9rsaZMrZPZlvihAsIVhXdnl9zcTDJh2cSk/jb MmvP8QIQ+5PFJ2Zf6dGQBvUUseYuyGu1VYxawhiB6ffxj5LPz+eWbQzCdg0+Ok7fMu6y 6ORk2QZWHaaw+b8AoFGJA6d8Ucyb6WzZq8kGw0eKMUrJuv5Xtdv68vtR1qIhMSZeBaNK udFg== X-Gm-Message-State: AOJu0Yx4vZDdoPk/zIPPzrhN71IV3EIRqPhABHZ0je/xMtjwK4QrYd4o 8Sq/32aIwX8l3L5ahqJcFNvP4mx6hpCdbjhxz20= X-Google-Smtp-Source: AGHT+IGcuY+s4vcx2qUgOz/iXmi7CR24FaMleyF6RIXHV1EXt0yBjqk8ofD4kT6PWs5yRvcFFxz7f+5O3CNnnizxDRI= X-Received: by 2002:a05:6402:b62:b0:558:23c1:fb28 with SMTP id cb2-20020a0564020b6200b0055823c1fb28mr68751edb.67.1704792352359; Tue, 09 Jan 2024 01:25:52 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Uros Bizjak Date: Tue, 9 Jan 2024 10:25:41 +0100 Message-ID: Subject: Re: [PATCH] match.pd: Convert {I, X}OR of two values ANDed with alien CSTs to PLUS [PR108477] To: Richard Biener Cc: Andrew Pinski , "gcc-patches@gcc.gnu.org" , Jeff Law Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.3 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 Tue, Jan 9, 2024 at 9:58=E2=80=AFAM Richard Biener w= rote: > > On Mon, 8 Jan 2024, Uros Bizjak wrote: > > > On Mon, Jan 8, 2024 at 5:57?PM Andrew Pinski wrote: > > > > > > On Mon, Jan 8, 2024 at 6:44?AM Uros Bizjak wrote: > > > > > > > > Instead of converting XOR or PLUS of two values, ANDed with two con= stants that > > > > have no bits in common, to IOR expression, convert IOR or XOR of sa= id two > > > > ANDed values to PLUS expression. > > > > > > I think this only helps targets which have leal like instruction. Als= o > > > I think it is the same issue as I recorded as PR 111763 . I suspect > > > BIT_IOR is more of a Canonical form for GIMPLE while we should handle > > > this in expand to decide if we want to use PLUS or IOR. > > > > For the pr108477.c testcase, expand pass expands: > > > > r_3 =3D a_2(D) & 1; > > p_5 =3D b_4(D) & 4294967292; > > _1 =3D r_3 | p_5; > > _6 =3D _1 + 2; > > return _6; > > > > The transformation ( | -> + ) is valid only when CST1 & CST2 =3D=3D 0, = so > > we need to determine values of constants. Is this information > > available in the expand pass? > > If there's single-uses then TER makes this info available. > > > IMO, the transformation from (ra | rb | cst) to (ra + rb + cst) as in > > the shown testcase would be beneficial when constructing control > > register values (see e.g. mesa-3d). We can use LEA instead of OR+ADD > > sequence in this case. > > The other possibility is to expose LEA as optab and making GIMPLE > instruction selection generate a direct internal function for that > (that would be the "better" way). There is LEA-like &TARGET_MEM_REF > but that has constraints on the addends mode (ptr_mode) which might > not fit what the target can do? Otherwise that would be an existing > way to do this computation as well. I think there is no need for a new optab. If we can determine at expand time that ANDed values are fed to the IOR/XOR expressions, then we can check the constants and emit PLUS RTX instead. RTL combine pass will then create LEA instruction from separate PLUS instructions. So, we can emit: op0 =3D and (a, CST1) op1 =3D and (b, CST2) op2 =3D plus (op0, op1) RTX sequence for (a & CST1) | (b & CST2) when CST1 & CST2 =3D=3D 0 and op0 =3D and (a, CST1) op1 =3D plus (op0, CST2) RTX sequence for (a & CST1) | CST2 when CST1 & CST2 =3D=3D 0 The above transformation is valid for IOR and XOR. x86 can't combine IOR/XOR in any meaningful way, but can combine the sequence of PLUS (together with MULT) RTXes to LEA. (BTW: I am not versed in the expand stuff, so a disclaimer is at hand ;) ) Uros.