From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qv1-xf2c.google.com (mail-qv1-xf2c.google.com [IPv6:2607:f8b0:4864:20::f2c]) by sourceware.org (Postfix) with ESMTPS id C98B63858D28 for ; Sat, 6 Aug 2022 09:51:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C98B63858D28 Received: by mail-qv1-xf2c.google.com with SMTP id mk9so3310588qvb.11 for ; Sat, 06 Aug 2022 02:51:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=AJCg3kwswR/TfRMAeyAqc7Xt9oJfZ/XWG4LSBiL/Go8=; b=YINp2Bn7OVSDZG0u2OwyIDk9gQA2tvfVlHrvwRayEV78AUSGOSeho+6YEp8s6XC/iB KiyTowbhdifVb8rlRqsOKEjrjX8sdZfomaTmtlZGumLALpDcofDcgSVSFffZjv7IM9FH 644Ao099NlOxSXGIjWWY1CVQZwPi4BcJLzqxmwNiqHbkNYPDVJ4Ln+a3HCx/9aC2ofzP nlsjUx6Lp5nbvbHO6aWqctFSJzIyO8uAQe0HJaIMS61VE7GiOh2BWwmi39KDM78HB9/t 4h7AGob8Se8jvZ6N4xZUtYplyNtmrhRIAXh1Yix9/KWvxui/iL30/2ESJ+XG5NhzsUC3 OjiQ== X-Gm-Message-State: ACgBeo3SdvOpSh5Bv5NTbmr8QD3I9Lcx/77Voe5YJvnHqO6aiOXZM8uW OGoxIkgweLv0q6eRp2kdVZqbIbVqWidyXN7O6jlm8q4P0PU= X-Google-Smtp-Source: AA6agR7hV+Wq6gXlPHz4OzJcxAwDU6Ddl81dT4H69XXP0HuRFkmktrRALJ+CeI4E8OZne3D8mzsWrkkQwrIY5eiAMpM= X-Received: by 2002:a05:6214:c67:b0:476:e8f8:4f6 with SMTP id t7-20020a0562140c6700b00476e8f804f6mr9141279qvj.125.1659779466041; Sat, 06 Aug 2022 02:51:06 -0700 (PDT) MIME-Version: 1.0 References: <014501d8a8cd$43413aa0$c9c3afe0$@nextmovesoftware.com> In-Reply-To: <014501d8a8cd$43413aa0$c9c3afe0$@nextmovesoftware.com> From: Uros Bizjak Date: Sat, 6 Aug 2022 11:51:00 +0200 Message-ID: Subject: Re: [x86_64 PATCH] Allow any immediate constant in *cmp_doubleword splitter. To: Roger Sayle Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, LOTS_OF_MONEY, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Aug 2022 09:51:08 -0000 On Fri, Aug 5, 2022 at 3:14 PM Roger Sayle wrote: > > > This patch tweaks i386.md's *cmp_doubleword splitter's predicate to > allow general_operand, not just x86_64_hilo_general_operand, to improve > code generation. As a general rule, i386.md's _doubleword splitters should > be post-reload splitters that require integer immediate operands to be > x86_64_hilo_int_operand, so that each part is a valid word mode immediate > constant. As an exception to this rule, doubleword patterns that must be > split before reload, because they require additional scratch registers, > can take advantage of this ability to create new pseudos, to accept > any immediate constant, and call force_reg on the high and/or low parts > if they are not suitable immediate operands in word mode. > > The benefit is shown in the new cmpti3.c test case below. > > __int128 x; > int foo() > { > __int128 t = 0x1234567890abcdefLL; > return x == t; > } > > where GCC with -O2 currently generates: > > movabsq $1311768467294899695, %rax > xorl %edx, %edx > xorq x(%rip), %rax > xorq x+8(%rip), %rdx > orq %rdx, %rax > sete %al > movzbl %al, %eax > ret > > but with this patch now generates: > > movabsq $1311768467294899695, %rax > xorq x(%rip), %rax > orq x+8(%rip), %rax > sete %al > movzbl %al, %eax > ret > > This patch has been tested on x86_64-pc-linux-gnu with make bootstrap > and make -k check, both with and without --target_board=unix{-m32}, > with no new failures. The first two new test cases aren't affected > by this patch, but as I had them in my directory, it seemed reasonable to > increase the testsuite's coverage of TImode comparison code generation. > Ok for mainline? > > 2022-08-05 Roger Sayle > > gcc/ChangeLog > * config/i386/i386.md (*cmp_doubleword): Change predicate > for x86_64_hilo_general_operand to general operand. Call > force_reg on parts that are not x86_64_immediate_operand. > > gcc/testsuite/ChangeLog > * gcc.target/i386/cmpti1.c: New test case. > * gcc.target/i386/cmpti2.c: Likewise. > * gcc.target/i386/cmpti3.c: Likewise. OK. Thanks, Uros.