From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 827793858292 for ; Fri, 17 Jun 2022 09:19:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 827793858292 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-338-B2Rnm2mlO9KjSCeTvKd_zQ-1; Fri, 17 Jun 2022 05:19:27 -0400 X-MC-Unique: B2Rnm2mlO9KjSCeTvKd_zQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9B304811E80; Fri, 17 Jun 2022 09:19:27 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.239]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 57FBDC08F22; Fri, 17 Jun 2022 09:19:27 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 25H9JOHG3661119 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 17 Jun 2022 11:19:24 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 25H9JNE33661118; Fri, 17 Jun 2022 11:19:23 +0200 Date: Fri, 17 Jun 2022 11:19:23 +0200 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] varasm: Fix up ICE in narrowing_initializer_constant_valid_p [PR105998] Message-ID: Reply-To: Jakub Jelinek References: <231F97C2-18BA-4984-9572-4CF495745126@suse.de> MIME-Version: 1.0 In-Reply-To: <231F97C2-18BA-4984-9572-4CF495745126@suse.de> X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2022 09:19:33 -0000 On Fri, Jun 17, 2022 at 10:37:45AM +0200, Richard Biener wrote: > > --- gcc/varasm.cc.jj 2022-06-06 12:18:12.792812888 +0200 > > +++ gcc/varasm.cc 2022-06-17 09:49:21.918029072 +0200 > > @@ -4716,7 +4716,8 @@ narrowing_initializer_constant_valid_p ( > > { > > tree inner = TREE_OPERAND (op0, 0); > > if (inner == error_mark_node > > - || ! INTEGRAL_MODE_P (TYPE_MODE (TREE_TYPE (inner))) > > + || VECTOR_TYPE_P (TREE_TYPE (inner)) > > Do we really want to allow all integer modes here regardless of a > composite type (record type for example)? I’d say !INTEGRAL_TYPE_P would > match the rest better. OTOH if we want to allow integer modes I fail to > see why to exclude vector types (but not complex, etc) I've excluded VECTOR_TYPE_P because those are the only types for which TYPE_MODE can be different from the raw type mode (so, SCALAR_INT_MODE_P was true but SCALAR_INT_TYPE_MODE still ICEd). Checking for INTEGRAL_TYPE_P seems reasonable to me though, and I'd say we also want to check the outer type too because nothing really checks it (at least for the first iteration, 2nd and further get it from checking of inner in the previous iteration). So like this if it passes bootstrap/regtest? 2022-06-17 Jakub Jelinek PR middle-end/105998 * varasm.cc (narrowing_initializer_constant_valid_p): Check SCALAR_INT_MODE_P instead of INTEGRAL_MODE_P, also break on ! INTEGRAL_TYPE_P and do the same check also on op{0,1}'s type. * c-c++-common/pr105998.c: New test. --- gcc/varasm.cc.jj 2022-06-17 11:07:57.883679019 +0200 +++ gcc/varasm.cc 2022-06-17 11:10:09.190932417 +0200 @@ -4716,7 +4716,10 @@ narrowing_initializer_constant_valid_p ( { tree inner = TREE_OPERAND (op0, 0); if (inner == error_mark_node - || ! INTEGRAL_MODE_P (TYPE_MODE (TREE_TYPE (inner))) + || ! INTEGRAL_TYPE_P (TREE_TYPE (op0)) + || ! SCALAR_INT_MODE_P (TYPE_MODE (TREE_TYPE (op0))) + || ! INTEGRAL_TYPE_P (TREE_TYPE (inner)) + || ! SCALAR_INT_MODE_P (TYPE_MODE (TREE_TYPE (inner))) || (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (op0))) > GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (inner))))) break; @@ -4728,7 +4731,10 @@ narrowing_initializer_constant_valid_p ( { tree inner = TREE_OPERAND (op1, 0); if (inner == error_mark_node - || ! INTEGRAL_MODE_P (TYPE_MODE (TREE_TYPE (inner))) + || ! INTEGRAL_TYPE_P (TREE_TYPE (op1)) + || ! SCALAR_INT_MODE_P (TYPE_MODE (TREE_TYPE (op1))) + || ! INTEGRAL_TYPE_P (TREE_TYPE (inner)) + || ! SCALAR_INT_MODE_P (TYPE_MODE (TREE_TYPE (inner))) || (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (op1))) > GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (inner))))) break; --- gcc/testsuite/c-c++-common/pr105998.c.jj 2022-06-17 11:09:11.196703834 +0200 +++ gcc/testsuite/c-c++-common/pr105998.c 2022-06-17 11:09:11.196703834 +0200 @@ -0,0 +1,12 @@ +/* PR middle-end/105998 */ + +typedef int __attribute__((__vector_size__ (sizeof (long long)))) V; + +V v; + +long long +foo (void) +{ + long long l = (long long) ((0 | v) - ((V) { } == 0)); + return l; +} Jakub