From patchwork Tue May 2 09:56:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 89301 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp483349vqo; Tue, 2 May 2023 02:57:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6F2C6xAlIAxRETZyYRscjCwAyoyKUPl1ZelOWpKvaGJnhl0Yup6TRdT4cotwRNHT+z7oZ9 X-Received: by 2002:a17:906:af15:b0:953:8bc2:69df with SMTP id lx21-20020a170906af1500b009538bc269dfmr18444800ejb.11.1683021446462; Tue, 02 May 2023 02:57:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683021446; cv=none; d=google.com; s=arc-20160816; b=QwBe1uL6Lt5d2DuH5YyxPADp3GYOcIQL0ydQ4BLPNc/lDDMalMHAYke39ZWx7OVHSt e+ZiR2UzkiM2iFYrYEW6WX7+fVMZlT7EQ7Xtb7dHT6qpvmMDIk5fkiybDqs07y1JrPCl QXgxwm2nslhi35+XG7DC3v1kWTWpdNn6Hj//4xhZApIY23eyYoULUriElbNq08Sm4Lao Pah4Gv30onvT/yfKJfr9xQCM3d/yMG2eNHCBjmMg7YvN63zkq5l5tTqpVubbCkLIN8VS c32uKrqYX64/L+jKRV8nTggr1tSam/104KNceT+OWOD7vFUaCi/jyligcCwJIBpsJzZ6 nFTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:sender:errors-to:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:user-agent:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=Llxzimuh8w/sfCZels3gSMwpmdDcvCe3My2fWPwwSp8=; b=xxQgLQjbc6XYPdWpOo99/0WVZrUhs8jGl+2r2WiB/pCSwwbV9FHXAN8YSLg3UesnIX g1m7C2AVYDbwzYPtqe+AxS2ekNN/O7F40V0ZuF2D3u4RJH1wFeFLH0iMJSE4OVK7+H5f CTGgLxeTfmp4VEsv60Oyov3/oLslxV2FlI+MUcSoLG2rSR3oAvq0qB8k9cv2Msnh4TUt UZrzjuB2IClxk4sgA9OAwhzqrhZiyOa4l4EHdsoUo5hz1j3goEjIMrW/R8FKLP78PUgt zBqgo3hujbYZhxka1JHta9wDYTTAQT3wOIMu4pur6NmoxHk/wQpeamhbHdw2Z4Ixf4EN 2jsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=m4Kz4HI2; 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 he42-20020a1709073daa00b00959c6dbc904si16940251ejc.258.2023.05.02.02.57.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 May 2023 02:57:26 -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=m4Kz4HI2; 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 955103857341 for ; Tue, 2 May 2023 09:57:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 955103857341 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683021432; bh=Llxzimuh8w/sfCZels3gSMwpmdDcvCe3My2fWPwwSp8=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=m4Kz4HI2/Ab/rnt/CKtHkDDxWqVFD5mkUrqvIQNDxPlw/jDSENXCmjLjEykQdPUW5 Uiwo5HHFs8ynWqx6P2iJosLwkjaYs50ftJL/BNT3qWHc/qxuRhIU2YIKftZzjxU0zm bv89uHXKwtVu9GFB1OluEztkhsiwUEMu3dA7VaDo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 072763858D20 for ; Tue, 2 May 2023 09:56:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 072763858D20 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 35DA31F8C2 for ; Tue, 2 May 2023 09:56:28 +0000 (UTC) Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 2C2002C141 for ; Tue, 2 May 2023 09:56:28 +0000 (UTC) Date: Tue, 2 May 2023 09:56:28 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/109672 - properly check emulated plus during vect User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, 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" Message-Id: <20230502095712.955103857341@sourceware.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764775896243312217?= X-GMAIL-MSGID: =?utf-8?q?1764775896243312217?= The following refactors the check for emulated vector support for the cases of plus, minus and negate. In the PR we end up with a SImode plus, supported by the target but emulated and in this context fail to verify we are dealing with exactly word_mode. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/109672 * tree-vect-stmts.cc (vectorizable_operation): For plus, minus and negate always check the vector mode is word mode. --- gcc/tree-vect-stmts.cc | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index c71e28737ee..3ad6a7d28d7 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -6384,29 +6384,26 @@ vectorizable_operation (vec_info *vinfo, } bool using_emulated_vectors_p = vect_emulated_vector_p (vectype); - if (!target_support_p) + if (!target_support_p || using_emulated_vectors_p) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "op not supported by target.\n"); + "op not supported by target.\n"); /* Check only during analysis. */ - if (maybe_ne (GET_MODE_SIZE (vec_mode), UNITS_PER_WORD) + if (((code == PLUS_EXPR || code == MINUS_EXPR || code == NEGATE_EXPR) + && maybe_ne (GET_MODE_SIZE (vec_mode), UNITS_PER_WORD)) || (!vec_stmt && !vect_can_vectorize_without_simd_p (code))) - return false; + { + if (dump_enabled_p ()) + dump_printf (MSG_NOTE, "using word mode not possible.\n"); + return false; + } if (dump_enabled_p ()) dump_printf_loc (MSG_NOTE, vect_location, "proceeding using word mode.\n"); using_emulated_vectors_p = true; } - if (using_emulated_vectors_p - && !vect_can_vectorize_without_simd_p (code)) - { - if (dump_enabled_p ()) - dump_printf (MSG_NOTE, "using word mode not possible.\n"); - return false; - } - int reduc_idx = STMT_VINFO_REDUC_IDX (stmt_info); vec_loop_masks *masks = (loop_vinfo ? &LOOP_VINFO_MASKS (loop_vinfo) : NULL); internal_fn cond_fn = get_conditional_internal_fn (code);