From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id D4E643858C20 for ; Wed, 14 Jun 2023 15:19:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D4E643858C20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686755985; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=dmLN8rtWZ+uu4xdUNZVBzAONgzQ7E1Lzo2cHJGyGmEU=; b=KkE4KF2dpk6snEO0D8uqCeJXoDfeeNU0bVbqkLgml0ta55HmCiYO2/pnDH7udANKEDakWV yWepMER/bQwOkfN/xAsIIb7i+YSK5RdN+hpUyIYd25cZZRtzSEXe1bvZfj9gOXsJXsDDgA XWZWkIl7J7kkew7pJfYCJnR2zWiPEkQ= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-152-sa60CleLMAC8gjeHc43w8g-1; Wed, 14 Jun 2023 11:19:42 -0400 X-MC-Unique: sa60CleLMAC8gjeHc43w8g-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DBEDA3828882; Wed, 14 Jun 2023 15:19:41 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.194.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 93E142166B25; Wed, 14 Jun 2023 15:19:41 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 35EFJcej1152954 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 14 Jun 2023 17:19:38 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 35EFJbmm1152953; Wed, 14 Jun 2023 17:19:37 +0200 Date: Wed, 14 Jun 2023 17:19:37 +0200 From: Jakub Jelinek To: Uros Bizjak Cc: Richard Biener , Roger Sayle , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] middle-end, i386, v3: Pattern recognize add/subtract with carry [PR79173] Message-ID: Reply-To: Jakub Jelinek References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-14.9 required=5.0 tests=BAYES_00,DKIM_INVALID,DKIM_SIGNED,KAM_DMARC_NONE,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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 List-Id: On Wed, Jun 14, 2023 at 04:45:48PM +0200, Uros Bizjak wrote: > +;; Helper peephole2 for the addcarry and subborrow > +;; peephole2s, to optimize away nop which resulted from uaddc/usubc > +;; expansion optimization. > +(define_peephole2 > + [(set (match_operand:SWI48 0 "general_reg_operand") > + (match_operand:SWI48 1 "memory_operand")) > + (const_int 0)] > + "" > + [(set (match_dup 0) (match_dup 1))]) > > Is this (const_int 0) from a recent patch from Roger that introduced: The first one I see is the one immediately above that: ;; Pre-reload splitter to optimize ;; *setcc_qi followed by *addqi3_cconly_overflow_1 with the same QI ;; operand and no intervening flags modifications into nothing. (define_insn_and_split "*setcc_qi_addqi3_cconly_overflow_1_" [(set (reg:CCC FLAGS_REG) (compare:CCC (neg:QI (geu:QI (reg:CC_CCC FLAGS_REG) (const_int 0))) (ltu:QI (reg:CC_CCC FLAGS_REG) (const_int 0))))] "ix86_pre_reload_split ()" "#" "&& 1" [(const_int 0)]) And you're right, the following incremental patch (I'd integrate it into the full patch with (*setcc_qi_addqi3_cconly_overflow_1_, *setccc, *setcc_qi_negqi_ccc_1_, *setcc_qi_negqi_ccc_2_): Split into NOTE_INSN_DELETED note rather than nop instruction. added to ChangeLog) passes all the new tests as well: --- gcc/config/i386/i386.md 2023-06-14 12:21:38.668657604 +0200 +++ gcc/config/i386/i386.md 2023-06-14 17:12:31.742625193 +0200 @@ -7990,16 +7990,6 @@ (set_attr "pent_pair" "pu") (set_attr "mode" "")]) -;; Helper peephole2 for the addcarry and subborrow -;; peephole2s, to optimize away nop which resulted from uaddc/usubc -;; expansion optimization. -(define_peephole2 - [(set (match_operand:SWI48 0 "general_reg_operand") - (match_operand:SWI48 1 "memory_operand")) - (const_int 0)] - "" - [(set (match_dup 0) (match_dup 1))]) - (define_peephole2 [(parallel [(set (reg:CCC FLAGS_REG) (compare:CCC @@ -8641,7 +8631,8 @@ "ix86_pre_reload_split ()" "#" "&& 1" - [(const_int 0)]) + [(const_int 0)] + "emit_note (NOTE_INSN_DELETED); DONE;") ;; Set the carry flag from the carry flag. (define_insn_and_split "*setccc" @@ -8650,7 +8641,8 @@ "ix86_pre_reload_split ()" "#" "&& 1" - [(const_int 0)]) + [(const_int 0)] + "emit_note (NOTE_INSN_DELETED); DONE;") ;; Set the carry flag from the carry flag. (define_insn_and_split "*setcc_qi_negqi_ccc_1_" @@ -8659,7 +8651,8 @@ "ix86_pre_reload_split ()" "#" "&& 1" - [(const_int 0)]) + [(const_int 0)] + "emit_note (NOTE_INSN_DELETED); DONE;") ;; Set the carry flag from the carry flag. (define_insn_and_split "*setcc_qi_negqi_ccc_2_" @@ -8669,7 +8662,8 @@ "ix86_pre_reload_split ()" "#" "&& 1" - [(const_int 0)]) + [(const_int 0)] + "emit_note (NOTE_INSN_DELETED); DONE;") ;; Overflow setting add instructions Jakub