From patchwork Tue Nov 14 00:55:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liuhongt X-Patchwork-Id: 164693 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1572076vqg; Mon, 13 Nov 2023 16:56:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IFT9KjcNsTNdcIWUD5wYNVFnefAvq9LcQm9d94yb4Mti8xO2JvTNPFXhBtGB5jz9RhIA+yM X-Received: by 2002:a05:620a:28c5:b0:76c:df5d:13a9 with SMTP id l5-20020a05620a28c500b0076cdf5d13a9mr999518qkp.58.1699923390792; Mon, 13 Nov 2023 16:56:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699923390; cv=pass; d=google.com; s=arc-20160816; b=vprFrkbrzg2TZbF+SryHUQwiFky/J55rb95t7L8HRu1BEw3tcrPROMLOoPKgXeZh7R +69PH77RUFsrWTi8LrV3ezXEZ7j1iS4pR3+uMVSg2U3iOMiQDOUsXWU79XDdSogQM7+D WyYArCnovigRHNzvJDlYTmmtKKdnUUSLkAsqiaIs56ZkonieOeZJnYa/bYTJtS4Qf8kJ u6GlKDTfWWYLklBzav5Es9n4UsqNfA88xhS0EplRB+MHKuNz++oxcbaXg3CDYrml5EIz 7kXvev2mne/3lXqTVFw+tlqf+rsrBvv8pxpzJXaCs4A9ZMknoEEQcR0sBDFmMBG2FcNI 5pmA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=3EhUJSXUPVliUqur74b+vCAasmglwatqf6edTX0XzZw=; fh=ChXOctppJn0KECDRINafwUY5xHRufGHaa0Ju9pddrcQ=; b=Xo/P4XZGetONvSm7EJROSPgE1Ysrk1REJyWrUFN4bubGnZPYhaDvTfHnO+8OB8lI7o lo0TgTZjH9bA6ZZFvnGym4coEMLhpDgWiZprr3Dj+EV46+JqbWGoKx73gcV+OZ5JtNbM amPlxEflcm3OZ1jNJb1ku2decKisk0rh1QXp6Ot8l7w/LIyUC0mZsCrIPTAY6nJjalRT Y/3+33J4FF3yjV9dmnk80RCob9VyTjzyEF50ezcuvWBPIo1Zy9lS1E5c1DbwEAJ0uI94 V2ktOH1DdS/iLlBDlAA/9rtQdYmxmyvQV9uvqLpbCPrFD/d5i7RzIIydyrjP8rDurb6x uv7Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YPjXJ8G9; 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=intel.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id 8-20020a05620a048800b0077a0d2652absi5326869qkr.759.2023.11.13.16.56.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 16:56: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=@intel.com header.s=Intel header.b=YPjXJ8G9; 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=intel.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8D6D6385DC2D for ; Tue, 14 Nov 2023 00:56:30 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by sourceware.org (Postfix) with ESMTPS id 2D11B3858CD1 for ; Tue, 14 Nov 2023 00:56:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2D11B3858CD1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2D11B3858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.55.52.136 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699923364; cv=none; b=g82gIMBiUoukj8hEbOpjqoOQL2yfITdEqQ9T1K+I87jmN/47uNEpQnj87ZO59VQduEQaPbJi3J0h9ea4gcWqjwIfHET1Z/T0LRWv7rNqa8KClc+QkWL3uKvZwp4T65Bk2lo/cVEGJvt2cnOYYJqs3w77QM6k5nNtQ3hvMJO8ir4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699923364; c=relaxed/simple; bh=rnWYjHpO+WvJSkleXosDLzbzKXzCN35vPqb6OF1mLqQ=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=DlDO6KMsRnepUdzJlAFJGWRYsUO/XIeA8y4W2wKiyG6mtL0Vct62umprU/1zsJHWmpGpVMxLl2nTx7KAAcSefwG7npaUheJbkfegSsTsC1ToiI12JgUonJwk4++y0nFcDWM9lt8cGF/GSISnZD0fh4eJeNxK0GVhXxeeeZ6o4TQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699923361; x=1731459361; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=rnWYjHpO+WvJSkleXosDLzbzKXzCN35vPqb6OF1mLqQ=; b=YPjXJ8G95EOBxXoiKAYPMthXo+rIEKGkzZ/jXFEKZGtzoqHq0G1cmODr 4+1ZAO+W69J8wFZ9Xq8ll5aOnqP9G42Y2teDw+A/ZJETNRikBpoIODwaj lBac2rs721CBlrJPWrXoLWHke661b9P1zQ+AOMRQUQrz30p4uOZa3fKSP sAP7c1fR49dP3abD+odcnXxEOuAItZdSDsNEmUvqHvlEyNIxfrbhCyGUt ukGQrs0uCZZphJJ7n+VgbQEdOZInT3iYCpXa7RcdcHpROloI6JUQZHW/R 4gv0kJ2y2zp6S0Ykkqw/XltBPRD4xKroT+Fyn04KargWfTr290d2u1oAC A==; X-IronPort-AV: E=McAfee;i="6600,9927,10893"; a="369879576" X-IronPort-AV: E=Sophos;i="6.03,299,1694761200"; d="scan'208";a="369879576" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2023 16:55:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,299,1694761200"; d="scan'208";a="12250220" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by orviesa001.jf.intel.com with ESMTP; 13 Nov 2023 16:55:56 -0800 Received: from shliclel4217.sh.intel.com (shliclel4217.sh.intel.com [10.239.240.127]) by shvmail03.sh.intel.com (Postfix) with ESMTP id 74910100571A; Tue, 14 Nov 2023 08:55:55 +0800 (CST) From: liuhongt To: gcc-patches@gcc.gnu.org Cc: crazylht@gmail.com, hjl.tools@gmail.com Subject: [PATCH] Fix ICE in vectorizable_nonlinear_induction with bitfield. Date: Tue, 14 Nov 2023 08:55:55 +0800 Message-Id: <20231114005555.2139904-1-hongtao.liu@intel.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782498869309335388 X-GMAIL-MSGID: 1782498869309335388 if (TREE_CODE (init_expr) == INTEGER_CST) init_expr = fold_convert (TREE_TYPE (vectype), init_expr); else gcc_assert (tree_nop_conversion_p (TREE_TYPE (vectype), TREE_TYPE (init_expr))); and init_expr is a 24 bit integer type while vectype has 32bit components. The "fix" is to bail out instead of asserting. Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. Ok for trunk?(and backport to GCC-13) gcc/ChangeLog: PR tree-optimization/112496 * tree-vect-loop.cc (vectorizable_nonlinear_induction): Return false when !tree_nop_conversion_p (TREE_TYPE (vectype), TREE_TYPE (init_expr). gcc/testsuite/ChangeLog: * gcc.target/i386/pr112496.c: New test. --- gcc/testsuite/gcc.target/i386/pr112496.c | 7 +++++++ gcc/tree-vect-loop.cc | 13 ++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr112496.c diff --git a/gcc/testsuite/gcc.target/i386/pr112496.c b/gcc/testsuite/gcc.target/i386/pr112496.c new file mode 100644 index 00000000000..c478fda9cce --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr112496.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct T { int x : 24; } v; +void f1(int x) { + while (v.x - ((v.x <<= 1) - v.x)) ; +} diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 1304b7ece79..75d69bbc30e 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -9429,9 +9429,16 @@ vectorizable_nonlinear_induction (loop_vec_info loop_vinfo, if (TREE_CODE (init_expr) == INTEGER_CST) init_expr = fold_convert (TREE_TYPE (vectype), init_expr); - else - gcc_assert (tree_nop_conversion_p (TREE_TYPE (vectype), - TREE_TYPE (init_expr))); + else if (!tree_nop_conversion_p (TREE_TYPE (vectype), TREE_TYPE (init_expr))) + { + /* INIT_EXPR could be a bit_field, bail out for such case. */ + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "nonlinear induction vectorization failed:" + " component type of vectype is not a nop conversion" + " from type of init_expr.\n"); + return false; + } switch (induction_type) {