From patchwork Fri May 5 12:18:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 90428 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp357850vqo; Fri, 5 May 2023 05:19:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4cK2wbkCypaZ6i26tbLmCu/Khzgbve6180LU4disUfaEZjICrqnfBjxI3GRpHeGEuoYdHj X-Received: by 2002:a17:906:eec5:b0:953:4775:baa7 with SMTP id wu5-20020a170906eec500b009534775baa7mr1070177ejb.52.1683289176101; Fri, 05 May 2023 05:19:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683289176; cv=none; d=google.com; s=arc-20160816; b=WHCIZCEZ3R/TNuEE3ofoaAdpuANNlQBIDeDx4o/MMZ2tzaAf8NP+3OjPzyKHTlNXxo upPIPBAosKbxobQ+8uFJHc8+rYekgBdsCX0CZq4r+e+BPOItvVbTbk+0OyC7lQlnfBIk ZFnud9YPPd64qtGT7+q3qVp3qgXWFQkwvQscC3J5i6RfBOVwcZeSUUd+pd8L/5EXxRnt 8fQMR8mr14JyTikzrLrVjxQ6qyCARjV6PkTX4dcR2oSWKaozs41NuhAiGL014f1QzXgw DPimTrIV0Ngwj8hpjRc5s9uf5B+rgH0dz7xbFO6H4f7tlxUTGnZslOAUGV4xFRuQF+QQ Baqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:message-id :mime-version:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=8bTfsf9b+mmVrXWfu+IqvdMG97GV7AwZLBQ5JTJHql8=; b=v3rZUbwJ1PCPtdyNcbK/5zAq2n2/LWolczVsBHxYR7v24LZGJtQEagci5Ko1ENNkLo 3onaWxZo0UhrGjBVE4om7FIezk81LrjCUOy7Ggxns662GCOSBZmxyUQ8UrHu99LsSPmG l3XN8P+f+YRBYUsuAS+lnsG0zKOAa2orKpi+jpS+Vzip2HdEDTUhoa9OnPySovryJOO+ mvrepWVCNGumrsedQFMpHsKYBP99JpMwhpm+I3r/NBleutnlKkk8gtffi6Z+yUtTfaY6 NCYLMrZ22BBJnetNMgX/uaa1PmeTX0KA9tKJXkZb1G4Nis+kEGY34h/OnGO+ym7fsnod ETNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=YqONB2Vm; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id 13-20020a170906224d00b0094f59d9ac6esi1341414ejr.1020.2023.05.05.05.19.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 05:19:36 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=YqONB2Vm; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2C0C638560B6 for ; Fri, 5 May 2023 12:19:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2C0C638560B6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683289169; bh=8bTfsf9b+mmVrXWfu+IqvdMG97GV7AwZLBQ5JTJHql8=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=YqONB2VmND7+AWZ6eCO5Ti2zP9PxT0y6tM90Iv8WruuEDZ6rqZ6GFRsZiuRbfd8TH AgonY8o+ZxL4ZAQS011i+1Z/syOI7PJh+m5e0wmMeqtZqwx8MMZsEOz19wON6VMjo/ 3cJAKODW9di9KmoD+nXEdyYEINF6l78nyGrSIxLI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 898C23858D20 for ; Fri, 5 May 2023 12:18:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 898C23858D20 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id BE14822A7E for ; Fri, 5 May 2023 12:18:43 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id AAF6813513 for ; Fri, 5 May 2023 12:18:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id HyKsKCP0VGQ/MgAAMHmgww (envelope-from ) for ; Fri, 05 May 2023 12:18:43 +0000 Date: Fri, 5 May 2023 14:18:43 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/109735 - conversion for vectorized pointer-diff MIME-Version: 1.0 Message-Id: <20230505121843.AAF6813513@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765056631117376786?= X-GMAIL-MSGID: =?utf-8?q?1765056631117376786?= There's handling in vectorizable_operation for POINTER_DIFF_EXPR requiring conversion of the result of the unsigned operation to a signed type. But that's conditional on the "default" kind of vectorization. In this PR it's shown the emulated vector path needs it and I think the masked operation case will, too (though we might eventually never mask an integral MINUS_EXPR). So the following makes that handling unconditional. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/109735 * tree-vect-stmts.cc (vectorizable_operation): Perform conversion for POINTER_DIFF_EXPR unconditionally. --- gcc/tree-vect-stmts.cc | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index cf5194ea444..61a2da4ecee 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -6657,8 +6657,8 @@ vectorizable_operation (vec_info *vinfo, new_stmt = gimple_build_assign (NULL_TREE, VIEW_CONVERT_EXPR, build1 (VIEW_CONVERT_EXPR, vectype, result_low)); - result_low = make_ssa_name (vectype); - gimple_assign_set_lhs (new_stmt, result_low); + new_temp = make_ssa_name (vectype); + gimple_assign_set_lhs (new_stmt, new_temp); vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi); } else if (masked_loop_p && mask_out_inactive) @@ -6734,18 +6734,19 @@ vectorizable_operation (vec_info *vinfo, AND it with a loop mask again. */ if (mask) loop_vinfo->vec_cond_masked_set.add ({ new_temp, mask }); + } - if (vec_cvt_dest) - { - new_temp = build1 (VIEW_CONVERT_EXPR, vectype_out, new_temp); - new_stmt = gimple_build_assign (vec_cvt_dest, VIEW_CONVERT_EXPR, - new_temp); - new_temp = make_ssa_name (vec_cvt_dest, new_stmt); - gimple_assign_set_lhs (new_stmt, new_temp); - vect_finish_stmt_generation (vinfo, stmt_info, - new_stmt, gsi); - } + if (vec_cvt_dest) + { + new_temp = build1 (VIEW_CONVERT_EXPR, vectype_out, new_temp); + new_stmt = gimple_build_assign (vec_cvt_dest, VIEW_CONVERT_EXPR, + new_temp); + new_temp = make_ssa_name (vec_cvt_dest, new_stmt); + gimple_assign_set_lhs (new_stmt, new_temp); + vect_finish_stmt_generation (vinfo, stmt_info, + new_stmt, gsi); } + if (slp_node) SLP_TREE_VEC_STMTS (slp_node).quick_push (new_stmt); else