From patchwork Thu Jan 11 14:07:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 187394 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1474565dyi; Thu, 11 Jan 2024 06:13:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IE3rRWgPT1Z2gmbIPx6IvYHq5JN11YRBe24kG2QfLIbXzkk01i/zg+fEnrVgVV8joJQx5g9 X-Received: by 2002:a05:622a:2298:b0:429:c547:7e12 with SMTP id ay24-20020a05622a229800b00429c5477e12mr835866qtb.99.1704982410225; Thu, 11 Jan 2024 06:13:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704982410; cv=pass; d=google.com; s=arc-20160816; b=D3n0pnk0pU+3gc4rQiDdk13/+efQDaKPprL9e1pgGjCEf7zgovCNW57li8ndSS3gGC Rs65HkI+rvvUmSXHpW4tV7OlNCt0X9jcqgl/67CtZALOMBJIKKQ2cxxjCpr2RxvLvUk2 ICx/g3yR4whsFy0Vs3AhRXWSrFNUJtx4jkRDLO56/7Xu492MlKZdtCffh8enBCU0dyyO 61wrS53G+qe5jbcUgK3GFCnkoxnUAqbtEfI3fD0l3KNev0clgw4v1Tsgs5TNznKR/YdY P2sSE+oh8J1MB/SO+WaZ1wwSu4RnruHOvYdevtcHCrADpipyPZpmZLGkWvymowRLUSdt 4BuQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:errors-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :subject:to:from:date:dkim-signature:dkim-signature:dkim-signature :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=d1i40s8Pn1V6Zui2sZbAkPdeeQnI0Oeifajw2wCbAiY=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=m1EJZ8nnyVFxwZ377dsOdgRCCFjxQ3J+/CUseBjBi0jDRCaLAFJkO4NyHjlefZ2W8N jFdiE5nUGRF/XuI+gAFdxc7A/twpm8H7FruU6FUfjSsEcp1hC/dEPCof9SbtUGLDySq2 4nAGD38cXxFM0/EbdenaWPWXZgnV/8+rfE4zVVEjOVTSp5msYE1Hwz6/gP7FS/QtrHEk SS613reYiFZ8zcPYJbPP5th/mZ6o48H2AfTRJtAy1iuDerJuvnwEtffKD8WP96lpJBPs Y3Yit36GT2DvX0cHALFFTESQ3/KCXyN815vXdKAXw9pBbZpmqUqmnYN1+vIn2zDnI6CT s5cA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=jElOEFxi; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=jElOEFxi; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id z10-20020ac87f8a000000b004277d662d67si1030030qtj.512.2024.01.11.06.13.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 06:13:30 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=jElOEFxi; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=jElOEFxi; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AB719386186A for ; Thu, 11 Jan 2024 14:13:28 +0000 (GMT) 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.223.131]) by sourceware.org (Postfix) with ESMTPS id 603193861846 for ; Thu, 11 Jan 2024 14:12:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 603193861846 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 603193861846 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704982357; cv=none; b=iC5aEd7uTCc/C8+k5NiOyE8aLJd7nKbZ2lTyV+FEy/Qz/tc9bfzdm9FgsgkMTwvOm0F2x/YOklWe7PxWhidrqXUTRVOZiTAfSCSCIZxHeqD+tu/wp3SZCYJ5vJTmVXgTsiNZLWTxUbI447Ek+TMptv+XTbIL61clMXlR45o9H2M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704982357; c=relaxed/simple; bh=5hrdRfuKRI4H3PVf5k6/1vyuX+i1NIgXRcwb7k4C+uI=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=nl4JBRjH2JLNO8cF1rWlrGWQhezGILBRNYlPxo52fklVMTcBMCoBE/0I7c8aVPH6bpe1dAh1+UL4SKgg+zuZAC7PvGqHCyMgOl51Y60x0RmDo6YuzSVhnhP4al0ww6rySQMpI1tEoZtP1VZyfmD6fZnHxKdWToi/MpXxfYGSB54= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [10.168.4.150] (unknown [10.168.4.150]) (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 smtp-out2.suse.de (Postfix) with ESMTPS id 4F7271FBAC for ; Thu, 11 Jan 2024 14:12:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1704982355; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=d1i40s8Pn1V6Zui2sZbAkPdeeQnI0Oeifajw2wCbAiY=; b=jElOEFxiRwuRPWTK0iHbLRrfH91fpbitXtiA18WPAxc4GaPUxpQrGGykOZFnh6AFCPaE5D oMqSABqAmudEl4VusOd7TnQ9T7Qx+VatC+fLAd4RF3zT7covegRvgKwXDQStxDBK73KSeS Lt8p/JhZC8KBC/g6Z+d1Pw2FeVuGlvw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1704982355; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=d1i40s8Pn1V6Zui2sZbAkPdeeQnI0Oeifajw2wCbAiY=; b=2s8Bw1K4KLV0URYsdxLtwfWrnO9daz6SLZbGxzlbVP7klIYy72NHChkFajm7xYLeA6GGcG /6he2NpdPU9G07BQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1704982355; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=d1i40s8Pn1V6Zui2sZbAkPdeeQnI0Oeifajw2wCbAiY=; b=jElOEFxiRwuRPWTK0iHbLRrfH91fpbitXtiA18WPAxc4GaPUxpQrGGykOZFnh6AFCPaE5D oMqSABqAmudEl4VusOd7TnQ9T7Qx+VatC+fLAd4RF3zT7covegRvgKwXDQStxDBK73KSeS Lt8p/JhZC8KBC/g6Z+d1Pw2FeVuGlvw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1704982355; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=d1i40s8Pn1V6Zui2sZbAkPdeeQnI0Oeifajw2wCbAiY=; b=2s8Bw1K4KLV0URYsdxLtwfWrnO9daz6SLZbGxzlbVP7klIYy72NHChkFajm7xYLeA6GGcG /6he2NpdPU9G07BQ== Date: Thu, 11 Jan 2024 15:07:34 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/112505 - bit-precision induction vectorization MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; none X-Spam-Score: 4.78 X-Spamd-Result: default: False [4.78 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_SPAM_SHORT(2.70)[0.899]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MISSING_MID(2.50)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_SPAM_LONG(2.69)[0.768]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-3.00)[100.00%] X-Spam-Status: No, score=-10.9 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Message-Id: <20240111141328.AB719386186A@sourceware.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787803635634939688 X-GMAIL-MSGID: 1787803635634939688 Vectorization of bit-precision inductions isn't implemented but we don't check this, instead we ICE during transform. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/112505 * tree-vect-loop.cc (vectorizable_induction): Reject bit-precision induction. * gcc.dg/vect/pr112505.c: New testcase. --- gcc/testsuite/gcc.dg/vect/pr112505.c | 14 ++++++++++++++ gcc/tree-vect-loop.cc | 9 +++++++++ 2 files changed, 23 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/vect/pr112505.c diff --git a/gcc/testsuite/gcc.dg/vect/pr112505.c b/gcc/testsuite/gcc.dg/vect/pr112505.c new file mode 100644 index 00000000000..56546c1095a --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr112505.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ + +short int w9; +struct T { + short a : 14; + int b; +}; +struct T v; +void zc() +{ + for(int i = 0; i < 4; i ++) + w9 *= v.b ? v.a-- < 0 : 0; +} diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 1bdad0fbe0f..38bd8267ee1 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -10037,6 +10037,15 @@ vectorizable_induction (loop_vec_info loop_vinfo, step_expr = STMT_VINFO_LOOP_PHI_EVOLUTION_PART (stmt_info); gcc_assert (step_expr != NULL_TREE); + if (INTEGRAL_TYPE_P (TREE_TYPE (step_expr)) + && !type_has_mode_precision_p (TREE_TYPE (step_expr))) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "bit-precision induction vectorization not " + "supported.\n"); + return false; + } tree step_vectype = get_same_sized_vectype (TREE_TYPE (step_expr), vectype); /* Check for backend support of PLUS/MINUS_EXPR. */