From patchwork Sat Mar 12 18:50:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Sayle X-Patchwork-Id: 51915 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8FDC23858C78 for ; Sat, 12 Mar 2022 18:50:46 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from server.nextmovesoftware.com (server.nextmovesoftware.com [162.254.253.69]) by sourceware.org (Postfix) with ESMTPS id 582D63858C78 for ; Sat, 12 Mar 2022 18:50:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 582D63858C78 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=nextmovesoftware.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nextmovesoftware.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nextmovesoftware.com; s=default; h=Content-Type:MIME-Version:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=WvjahZs2iLjutqoKX+z1ERQ4ghgmIQghp1iJhkIJr8Y=; b=Ib4NHe2pp69q+td1WRnOrFVhZC lrHmOoGCvQjEtfRQ7uaMY/GhaORa3T9VBck8my/EN5zrHkh4GvquecLhYtozw2XT8cNULbTWZOi2h wJFaAaaU2V7kKqEO3d6skeMsj2eMFudvRJDSsKcdJZK+elxgabCc/P0kdDeRGYRGmCAKRUc7Kvo2K CaIDcl4Svs+1on88Za0Cucmbio+pgannTl+/G68UgDpN9O0JBIukUN07s3+Cxj8/+PHEv2Mr0iGV3 6SHKC3UR5jLbnDpQnE08JBiy9HpVIrm0yXaWjAwf9W6ZWUudqMuc6QjZaRanx3ETnmFsu+3L05+k5 p3222aEw==; Received: from host86-186-213-42.range86-186.btcentralplus.com ([86.186.213.42]:59425 helo=Dell) by server.nextmovesoftware.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nT6ov-00041l-7o; Sat, 12 Mar 2022 13:50:29 -0500 From: "Roger Sayle" To: "'GCC Patches'" Subject: [x86 PATCH] Fix libitm.c/memset-1.c test fails with new peephole2s. Date: Sat, 12 Mar 2022 18:50:27 -0000 Message-ID: <003401d83642$0b222c40$216684c0$@nextmovesoftware.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: Adg2QQvDdAqcia+dQC6+vrR0v1X6Ag== Content-Language: en-gb X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server.nextmovesoftware.com X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - nextmovesoftware.com X-Get-Message-Sender-Via: server.nextmovesoftware.com: authenticated_id: roger@nextmovesoftware.com X-Authenticated-Sender: server.nextmovesoftware.com: roger@nextmovesoftware.com X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" My sincere apologies for the breakage, but alas handling SImode in the recently added "xorl;movb -> movzbl" peephole2 turns out to be slightly more complicated that just using SWI48 as a mode iterator. I'd failed to check the machine description carefully, but the *zero_extendsi2 define_insn is conditionally defined, based on x86 target tuning using TARGET_ZERO_EXTEND_WITH_AND, and therefore unavailable on 486 and pentium unless optimizing the code for size. It turns out that the libitm testsuite specifies -m486 with make check RUNTESTFLAGS="--target_board='unix{-m32}'" and therefore encounters/catches my oversight. Fixed by adding the appropriate conditions to the new peephole2 patterns. It don't think it's worth the effort to provide an equivalent optimization for these (very) old architectures. Tested on x86_64-pc-linux-gnu with make bootstrap and make -k check with no new failures. Confirmed using RUNTESTFLAGS that this fixes the above failure, and the recently added testcase with -march=i486. Ok for mainline? 2022-03-12 Roger Sayle gcc/ChangeLog * config/i386/i386.md (peephole2 xorl;movb -> movzbl): Disable transformation when *zero_extendsi2 is not available. gcc/testsuite/ChangeLog * gcc.target/i386/pr98335.c: Skip this test if tuning for i486 or pentium, and not optimizing for size. Sorry for the noise. Roger diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index c8fbf60..80b5974 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -4316,7 +4316,10 @@ (clobber (reg:CC FLAGS_REG))]) (set (strict_low_part (match_operand:SWI12 1 "general_reg_operand")) (match_operand:SWI12 2 "nonimmediate_operand"))] - "REGNO (operands[0]) == REGNO (operands[1])" + "REGNO (operands[0]) == REGNO (operands[1]) + && ( != 4 + || !TARGET_ZERO_EXTEND_WITH_AND + || !optimize_function_for_speed_p (cfun))" [(set (match_dup 0) (zero_extend:SWI48 (match_dup 2)))]) ;; Likewise, but preserving FLAGS_REG. @@ -4324,7 +4327,10 @@ [(set (match_operand:SWI48 0 "general_reg_operand") (const_int 0)) (set (strict_low_part (match_operand:SWI12 1 "general_reg_operand")) (match_operand:SWI12 2 "nonimmediate_operand"))] - "REGNO (operands[0]) == REGNO (operands[1])" + "REGNO (operands[0]) == REGNO (operands[1]) + && ( != 4 + || !TARGET_ZERO_EXTEND_WITH_AND + || !optimize_function_for_speed_p (cfun))" [(set (match_dup 0) (zero_extend:SWI48 (match_dup 2)))]) ;; Sign extension instructions diff --git a/gcc/testsuite/gcc.target/i386/pr98335.c b/gcc/testsuite/gcc.target/i386/pr98335.c index 7fa7ad7..bf731b4 100644 --- a/gcc/testsuite/gcc.target/i386/pr98335.c +++ b/gcc/testsuite/gcc.target/i386/pr98335.c @@ -1,5 +1,10 @@ /* { dg-do compile } */ /* { dg-options "-O2" } */ +/* { dg-skip-if "" { *-*-* } { "-march=i[45]86" } { "-O[sz]" } } */ +/* { dg-skip-if "" { *-*-* } { "-march=pentium" } { "-O[sz]" } } */ +/* { dg-skip-if "" { *-*-* } { "-mtune=i[45]86" } { "-O[sz]" } } */ +/* { dg-skip-if "" { *-*-* } { "-mtune=pentium" } { "-O[sz]" } } */ + union Data { char a; short b; }; char c;