From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 2A8B93858C31; Thu, 27 Apr 2023 11:21:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2A8B93858C31 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682594519; bh=up7nYz/MyBx6V6CNl4Mssf8Z44+0x94rAvJ7fqoSXI4=; h=From:To:Subject:Date:From; b=EXz7G9BKCpijEZelJlRx7UW0bDa7BYCY2k07Z1FLHw1CbS7WRLDWoY26Ssyb0ZHcX YP/Cb3QY+OEf4cmvW2hPqQBbUfUjo6cQAj0NF+E0CtDg49s/mZQI5XABSSzWJAORRf BP8ee5ZJMkgcnT+/35QZU0EX8we91wY7+hpDwahk= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-297] wrong GIMPLE from (bit_field_ref CTOR ..) simplification X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: 0403d2957929fa12bbd379e3839a8d0c2160576f X-Git-Newrev: a82c6ab0aade4124e1903dda6f6f85c4c317fcec Message-Id: <20230427112159.2A8B93858C31@sourceware.org> Date: Thu, 27 Apr 2023 11:21:59 +0000 (GMT) List-Id: https://gcc.gnu.org/g:a82c6ab0aade4124e1903dda6f6f85c4c317fcec commit r14-297-ga82c6ab0aade4124e1903dda6f6f85c4c317fcec Author: Richard Biener Date: Mon Apr 24 13:20:25 2023 +0200 wrong GIMPLE from (bit_field_ref CTOR ..) simplification When we simplify a BIT_FIELD_REF of a CTOR like { _1, _2, _3, _4 } and attempt to produce (view converted) { _1, _2 } for a selected subset we fail to realize this cannot be done from match.pd since we have no way to write the resulting CTOR "operation" and the built CTOR { _1, _2 } isn't a GIMPLE value. This kind of simplifications have to be done in forwprop (or would need a match.pd syntax extension) where we can split out the CTOR to a separate stmt. The following disables this particular simplification when we are simplifying GIMPLE. With enhanced IL checking this otherwise causes ICEs in the testsuite from vectorized code. * match.pd (BIT_FIELD_REF CONSTRUCTOR@0 @1 @2): Do not create a CTOR operand in the result when simplifying GIMPLE. Diff: --- gcc/match.pd | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gcc/match.pd b/gcc/match.pd index 34e1a5c1b46..c4320781f5b 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -7456,10 +7456,15 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) ? type : build_vector_type (TREE_TYPE (TREE_TYPE (ctor)), count * k)); + /* We used to build a CTOR in the non-constant case here + but that's not a GIMPLE value. We'd have to expose this + operation somehow so the code generation can properly + split it out to a separate stmt. */ res = (constant_p ? build_vector_from_ctor (evtype, vals) - : build_constructor (evtype, vals)); + : (GIMPLE ? NULL_TREE : build_constructor (evtype, vals))); } - (view_convert { res; })))))) + (if (res) + (view_convert { res; }))))))) /* The bitfield references a single constructor element. */ (if (k.is_constant (&const_k) && idx + n <= (idx / const_k + 1) * const_k)