From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by sourceware.org (Postfix) with ESMTPS id 05D503858410 for ; Tue, 11 Jun 2024 22:38:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 05D503858410 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 05D503858410 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::52d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718145524; cv=none; b=mThwNa8I0ORPDqGdntca/h0ItyNf7Du17jDPuitNT3WPRrlnEZaNl/Epg33bQhnj94LzNgycJHs5VQhZFH4zU7WPoi1gDdoGlENrofyv7AyTdFRxW9ugVP0gtOGUtX/wh7rUEEg0Bs3O+vScPp2jPin9EofC7IebMVBSAVbU6k4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718145524; c=relaxed/simple; bh=M5gGcZNbNLhOc6lvi+2hphYPzVZN/7trqFfWvhK7GSw=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=dVovq8P+zoapF318LCtKvhTuqmyzHpgOpU9pFVZgIMWX318u27HpLLQ5w6mFT83tGMjAyml94ET/fDHw+yKsjcMMmmf8g/+Q8alLgWdePVpiRxgYGO5KfnYblnyivR5MKVGQuAw5JApFnMyvRZMY5u2Xc/nY1rV/xHcOEa3alx4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-6e40d54e4a3so3420949a12.0 for ; Tue, 11 Jun 2024 15:38:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718145522; x=1718750322; 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=F6FJtpFDaNHzl7Hyzw5cWLDxq3Bc7Vx41KorBMWH3Lo=; b=KmJyWAoWjNq6UPxnQZtS6gxRYaFotN9YMgbJubQfePXG9X3tlFju3sQuZGs1mJsWjW EKl0yf0+/O3IJpL1MhQ1Gdr0qoJFtFJqHFwRCTauu6mCGKVrtvoo3p46wLS63boMdCsO WongPZk+Ta81UoUXYmjg7R5FE+UD2+cRPNP1NzOjVOIAXwMPr7G1+jDKzdd4b+LpolsV LnHzXqQP282JAKn5PN6JQ9AUnvU6cV6t7XfyeoZz4KILmj7ZNALgZQLpHyPVCtQGAwnR eqDYEZsJNz/i4JU+YCVyVGM2qT74/hXUWq6BG4mzsgYKUHPDn6swYB4g3cZuoFRAk58i TVVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718145522; x=1718750322; 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=F6FJtpFDaNHzl7Hyzw5cWLDxq3Bc7Vx41KorBMWH3Lo=; b=iOTVEtAp5Bh4/a6sM3A+Vl3VddxhXQM73RQAGyP5P93P7NxrjOpyAAgwzM4JSrnV8k qx27OKkJLPhAbjcpD62bKHuGtY+1LRtLmUVoMDJQTCeNiMqC1QtdJqjzBqSB1oQNJ3KM Ze9/7UtkOHmGRwQCM1lIklX3J2+yLfxvwGdQumPOZgFasxERyLbAVuijIvJqFtU/CQv8 4LERAYMeoTO9pVfpDe33unS1wPsmGBFz8D6A6Epgv7B644we30eL5LWpyw3rYUhfiyBO vGHunvozyucHyz68rnDM3ZKI5ly7e9dZEjDkoFUz2qnqyzySl0YCD15EQW701/YrqBpr AVIg== X-Gm-Message-State: AOJu0YzpCuRNjNwumUyRHiD2cwg9xnJITIlfpLBrnwGiOCQwxpWciKYI Yhx9dihWaN0U375jQNFnKU2/gnc2PF67rAoqcHn8EZDEeSxqAXB+5X3GK2SDy5929irqLVhT4dD +mm0IgcU7G3OIFor8RVAhgAMaC1dNpgPls+w= X-Google-Smtp-Source: AGHT+IEeVoh41TxHhbzF+SWAS+JO+rM9A9MZV8ZN/YbYy/CKWqgDpPzM3Uc9reZW/GcyYAYnP2i9OXUbSDjpt/BXS5M= X-Received: by 2002:a17:902:ea07:b0:1f4:b2ce:8dbe with SMTP id d9443c01a7336-1f83b55fd32mr3235935ad.9.1718145521907; Tue, 11 Jun 2024 15:38:41 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Andrew Pinski Date: Tue, 11 Jun 2024 15:38:29 -0700 Message-ID: Subject: Re: [committed] [v2] More logical op simplifications in simplify-rtx.cc To: Jeff Law Cc: "gcc-patches@gcc.gnu.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,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 Sat, May 25, 2024 at 11:42=E2=80=AFAM Jeff Law w= rote: > > This is a revamp of what started as a target specific patch. > > Basically xalan (corrected, I originally thought it was perlbench) has a > bitset implementation with a bit of an oddity. Specifically setBit will > clear the bit before it is set: > > > if (bitToSet < 32) > > { > > fBits1 &=3D ~mask; > > fBits1 |=3D mask; > > } > > else > > { > > fBits2 &=3D ~mask; > > fBits2 |=3D mask; > > } > > We can clean this up pretty easily in RTL with a small bit of code in > simplify-rtx. While xalan doesn't have other cases, we can synthesize > tests pretty easily and handle them as well. > > > It turns out we don't actually have to recognize this stuff at the bit > level, just standard logical identities are sufficient. For example > > (X | Y) & ~Y -> X & ~Y > > > > Andrew P. might poke at this at the gimple level. The type changes > kindof get in the way in gimple but he's much better at match.pd than I > am, so if he wants to chase it from the gimple side, I'll fully support > that. So we already have this pattern (without the type change) in gimple: /* (~x | y) & x -> x & y */ /* (~x & y) | x -> x | y */ (simplify (bitop:c (rbitop:c @2 @1) @0) (with { bool wascmp; } (if (bitwise_inverted_equal_p (@0, @2, wascmp) && (!wascmp || element_precision (type) =3D=3D 1)) (bitop @0 @1)))) The problem is bitwise_inverted_equal_p does not see that: c.0_4 =3D (signed char) _1; _5 =3D ~c.0_4; _16 =3D (charD.11) _5; and c_11 =3D (charD.11) _1; are bitwise inversions of each other. I filed https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D115449 to keep track of this. Thanks, Andrew Pinski > > Bootstrapped and regression tested on x86. Also run through my tester > on its embedded targets. > > Pushing to the trunk. > > jeff >