From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by sourceware.org (Postfix) with ESMTPS id 5C8C83858C27 for ; Fri, 4 Aug 2023 06:37:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5C8C83858C27 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2b9bf52cd08so26346511fa.2 for ; Thu, 03 Aug 2023 23:37:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691131052; x=1691735852; 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=YR5n4HDILLrNxyLUsVEgnmmoXjrsDlYnTQ2Wq/7b9pI=; b=Xz1u/251ih24Pr4S7X6xY1aBPpCfpyPX0LW85xO5/6qSOSEiSdBEynvjwbFvanoQ+2 I57SqimeQNsE6DeNXDDbIKHI5CRZCpsEn3Ej9w591wQUKTbA2uDv2h8w303OkUgoaqwt OqnEhL9yYOlOCfjD2pnipVHxmLJAz4hBxGTjtXNV0Dr9yOiTVfwFrZzk2dML0lAh5snn 8VBgNLQPo+qB4gTp74GJESNIInXMZD4FzEiBedR2rGnm7iV/OloNhTKfy5vhW05Js6i7 TW3Ube0dtRJJEVnh1ypOfyBb619QtI4Z791fQJx32/RXmil9yS4myLQV6HjgT18uARE4 6SOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691131052; x=1691735852; 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=YR5n4HDILLrNxyLUsVEgnmmoXjrsDlYnTQ2Wq/7b9pI=; b=TfdTckvM4mGTL/JzZesmMGr94rX1r+qIoLzp4Van/YLaFwCM/19VoIa9jyFByd+Ojl 4qmepQSHmV3t5XECwhfbN6rnL2RJENZhwO4Usv1tqvi3L3+wZGcqqe74P0Or/UMkyhz7 jKXvir26TONGYwbkMccC5cAgxYiMHltPSkfpcUh+i4wllktzZRJ9RjpASVnTpe3EIf+m sT0oN6Ahka+yd6fVMyCkdt8+dhh6je/5Cacwe9Zfp0UlnahDhP4P5ncARD2pa2xsClZ/ HNfp6vQ1PsQqTefbFQOrZ1TE689lidg8Bj1EEg9dBrLNtvDOL7S0WZ/YHbS5IuiJ+zed a+9A== X-Gm-Message-State: AOJu0YwchwZZtU+xnmaqt67roRu+VNFAezPk0fr7sSWpbH5AAmNCANut yTOSxdaJ63pWiTZWNB7oQ5gaJkf1fo3HZpRWO8Y= X-Google-Smtp-Source: AGHT+IHScZr6/4kfJyQojJ3RXhmqfzwGVkivFMEQe38jFSaeZKLp6XRBnI6NuQfRYhhKPF3gWYRrZjeADiMEOSNCDiU= X-Received: by 2002:a2e:9b18:0:b0:2b9:f1b3:ac3b with SMTP id u24-20020a2e9b18000000b002b9f1b3ac3bmr723872lji.39.1691131051573; Thu, 03 Aug 2023 23:37:31 -0700 (PDT) MIME-Version: 1.0 References: <20230316152706.2214124-1-manolis.tsamis@vrull.eu> <8bd8b246-a252-0e05-414c-ab1e35975aea@gmail.com> <76e4d7a6-65af-7af3-2f33-d935cf628214@gmail.com> In-Reply-To: <76e4d7a6-65af-7af3-2f33-d935cf628214@gmail.com> From: Richard Biener Date: Fri, 4 Aug 2023 08:37:19 +0200 Message-ID: Subject: Re: [PATCH v1] [RFC] Improve folding for comparisons with zero in tree-ssa-forwprop. To: Jeff Law Cc: Manolis Tsamis , Philipp Tomsich , Andrew MacLeod , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.8 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 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 Thu, Aug 3, 2023 at 5:21=E2=80=AFPM Jeff Law wro= te: > > > > On 8/3/23 01:04, Richard Biener wrote: > > On Wed, Aug 2, 2023 at 4:08=E2=80=AFPM Manolis Tsamis wrote: > >> > >> Hi all, > >> > >> I'm pinging to discuss again if we want to move this forward for GCC14= . > >> > >> I did some testing again and I haven't been able to find obvious > >> regressions, including testing the code from PR86270 and PR70359 that > >> Richard mentioned. > >> I still believe that zero can be considered a special case even for > >> hardware that doesn't directly benefit in the comparison. > >> For example it happens that the testcase from the commit compiles to > >> one instruction less in x86: > >> > >> .LFB0: > >> movl (%rdi), %eax > >> leal 1(%rax), %edx > >> movl %edx, (%rdi) > >> testl %eax, %eax > >> je .L4 > >> ret > >> .L4: > >> jmp g > >> > >> vs > >> > >> .LFB0: > >> movl (%rdi), %eax > >> addl $1, %eax > >> movl %eax, (%rdi) > >> cmpl $1, %eax > >> je .L4 > >> ret > >> .L4: > >> xorl %eax, %eax > >> jmp g > >> > >> (The xorl is not emitted when testl is used. LLVM uses testl but also > >> does xor eax, eax :) ) > >> Although this is accidental, I believe it also showcases that zero is > >> a preferential value in various ways. > >> > >> I'm running benchmarks comparing the effects of this change and I'm > >> also still looking for testcases that result in problematic > >> regressions. > >> Any feedback or other concerns about this are appreciated! > > > > My comment from Apr 24th still holds, IMO this is something for > > instruction selection (aka the ISEL pass) or the out-of-SSA tweaks > > we do during RTL expansion (see insert_backedge_copies) > I'm still generally supportive of biasing to zero, but as Richi has > noted the current implementation needs to be pushed further back into > the pipeline, preferably all the way to isel or gimple->rtl expansion. Note the main reason is that if you only "fix" forwprop you miss other plac= es that will happily undo this. As the intent is to get better instruction selection doing the canoncalization at RTL expansion sounds like the best idea to me. Richard. > Jeff