From patchwork Fri Aug 6 12:24:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 1514330 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=IDZ/mSKy; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gh4Sx4sSsz9sW5 for ; Fri, 6 Aug 2021 22:25:53 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C9F4539B584B for ; Fri, 6 Aug 2021 12:25:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C9F4539B584B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1628252750; bh=eNczBw5TdfAcTpK+qkvTHmUuv8wwoU/+tY9YvHvOwtc=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=IDZ/mSKyRH/I5cbZqAhDGVUfHV9KWu5xxhkFeDm9OUmSsMNlOiQoB7DP996KV+1Z1 xco6I97sizOfXaEPuZ/595xJ6jf/6DwUqtTU4Y5KzImCHdQouqN8Za06osHb8RPAx+ MHXCgiLxziOIudbq7COUCJBHj7VG4ATQmPNJzayU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by sourceware.org (Postfix) with ESMTPS id 19AFC3AA941C for ; Fri, 6 Aug 2021 12:24:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 19AFC3AA941C Received: by mail-qt1-x833.google.com with SMTP id c5so6263119qtp.13 for ; Fri, 06 Aug 2021 05:24:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=eNczBw5TdfAcTpK+qkvTHmUuv8wwoU/+tY9YvHvOwtc=; b=THAB/5qGTlm2mFe2cEoT1yW9SdYMb73hQpPHUV6x17yKfPDQpRjhunG27o4I7Sgoar cSFSa5MilQ6JDaTMcUoB7p6A7I/Pw73/VfYjykjUJWbzFfeTj5srUZkejHqTPtXo4xJw teRVloksRgMVzjislxITJZAujOHqkpIj5cNeuc9RvYiSCtM9kzPMsrC0WX2Jil3HUZoX yxK9yfQr7yrpP5m92fsBZ2Gqp7V+HyYaKeDqESXbHNtnf7EFhxSlCF1VVdO+l1Pli75b jHMcVr2plzC8UhbwjDDih86tC5ZVcSF/GwYSTUY1T0PAzRznOb2rWOy5vzgdLLN7T/KE fLkg== X-Gm-Message-State: AOAM532fpqpj7OHQDV2u1XC3/h2nmiNKvu42l72hUSurb96tjlvIV2Gs 1ZQJGn1dSZjGyVAUfEzIBBeMGBhAbngIIJ4avhIM53zNo5ZJPg== X-Google-Smtp-Source: ABdhPJx8IgsQpkngqHFhF7hWLCDk4JzwicWCQd3ab790Px6lsRhVoCfW0f0dfaji6OR15UVv0k1AJIIVTwzE/4bD5iE= X-Received: by 2002:ac8:5f94:: with SMTP id j20mr8688571qta.225.1628252686293; Fri, 06 Aug 2021 05:24:46 -0700 (PDT) MIME-Version: 1.0 Date: Fri, 6 Aug 2021 14:24:35 +0200 Message-ID: Subject: [PATCH] i386: Fix conditional move reg-to-reg move elimination peepholes [PR101797] To: "gcc-patches@gcc.gnu.org" X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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: , X-Patchwork-Original-From: Uros Bizjak via Gcc-patches From: Uros Bizjak Reply-To: Uros Bizjak Cc: Roger Sayle Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Add missing operand predicate, otherwise any RTX will match. 2021-08-06 Uroš Bizjak gcc/ PR target/101797 * config/i386/i386.md (cmove reg-to-reg move elimination peephole2s): Add general_gr_operand predicate to operand 3. gcc/testsuite/ PR target/101797 * gcc.target/i386/pr101797.c: New test. Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. Pushed to master. Uros. diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 51e8b475bca..bc1c30b77f4 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -19428,7 +19428,7 @@ (parallel [(set (reg FLAGS_REG) (match_operand 5)) (set (match_dup 0) (match_operand:SWI248 6))]) (set (match_operand:SWI248 2 "general_reg_operand") - (match_operand:SWI248 3)) + (match_operand:SWI248 3 "general_gr_operand")) (set (match_dup 0) (if_then_else:SWI248 (match_operator 4 "ix86_comparison_operator" [(reg FLAGS_REG) (const_int 0)]) @@ -19456,7 +19456,7 @@ ;; mov r2,r3; mov r0,r1; dec r0; cmov r0,r2 -> dec r1; mov r0,r3; cmov r0, r1 (define_peephole2 [(set (match_operand:SWI248 2 "general_reg_operand") - (match_operand:SWI248 3)) + (match_operand:SWI248 3 "general_gr_operand")) (set (match_operand:SWI248 0 "general_reg_operand") (match_operand:SWI248 1 "general_reg_operand")) (parallel [(set (reg FLAGS_REG) (match_operand 5)) diff --git a/gcc/testsuite/gcc.target/i386/pr101797.c b/gcc/testsuite/gcc.target/i386/pr101797.c new file mode 100644 index 00000000000..d5cc34e54a8 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr101797.c @@ -0,0 +1,15 @@ +/* PR target/101797 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int a; +int main() { + int b, c, d, e = 0; + if (a) { + c += a; + e = ~(a % c); + e || c || (b & d); + } + a = e; + return 0; +}