From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 6EFB33855023 for ; Tue, 22 Jun 2021 11:16:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6EFB33855023 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 16A2431B; Tue, 22 Jun 2021 04:16:49 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.126]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5F4163F694; Tue, 22 Jun 2021 04:16:48 -0700 (PDT) From: Richard Sandiford To: Tamar Christina Mail-Followup-To: Tamar Christina , Richard Biener , nd , "gcc-patches\@gcc.gnu.org" , richard.sandiford@arm.com Cc: Richard Biener , nd , "gcc-patches\@gcc.gnu.org" Subject: Re: [PATCH 1/4]middle-end Vect: Add support for dot-product where the sign for the multiplicant changes. References: <7q3oonr2-92r0-8o9q-s27q-9r735s4n3s3@fhfr.qr> Date: Tue, 22 Jun 2021 12:16:47 +0100 In-Reply-To: (Richard Sandiford's message of "Tue, 22 Jun 2021 11:56:20 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Tue, 22 Jun 2021 11:16:50 -0000 Richard Sandiford writes: >> @@ -992,21 +1029,27 @@ vect_recog_dot_prod_pattern (vec_info *vinfo, >> /* FORNOW. Can continue analyzing the def-use chain when this stmt in a phi >> inside the loop (in case we are analyzing an outer-loop). */ >> vect_unpromoted_value unprom0[2]; >> + enum optab_subtype subtype = optab_vector; >> if (!vect_widened_op_tree (vinfo, mult_vinfo, MULT_EXPR, WIDEN_MULT_EXPR, >> - false, 2, unprom0, &half_type)) >> + false, 2, unprom0, &half_type, &subtype)) >> + return NULL; >> + >> + if (subtype == optab_vector_mixed_sign >> + && TYPE_UNSIGNED (unprom_mult.type) >> + && TYPE_PRECISION (half_type) * 4 > TYPE_PRECISION (unprom_mult.type)) >> return NULL; > > Isn't the final condition here instead that TYPE1 is narrower than TYPE2? > I.e. we need to reject the case in which we multiply a signed and an > unsigned value to get a (logically) signed result, but then zero-extend > it (rather than sign-extend it) to the precision of the addition. > > That would make the test: > > if (subtype == optab_vector_mixed_sign > && TYPE_UNSIGNED (unprom_mult.type) > && TYPE_PRECISION (unprom_mult.type) < TYPE_PRECISION (type)) > return NULL; > > instead. And folding that into the existing test gives: /* If there are two widening operations, make sure they agree on the sign of the extension. The result of an optab_vector_mixed_sign operation is signed; otherwise, the result has the same sign as the operands. */ if (TYPE_PRECISION (unprom_mult.type) != TYPE_PRECISION (type) && (subtype == optab_vector_mixed_sign ? TYPE_UNSIGNED (unprom_mult.type) : TYPE_SIGN (unprom_mult.type) != TYPE_SIGN (half_type))) return NULL; Thanks, Richard