From patchwork Wed Mar 1 09:11:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 65830 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 55BBC3858023 for ; Wed, 1 Mar 2023 09:12:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 55BBC3858023 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677661940; bh=WQ6ndaDa43YHXO7gz4cNsbR+pEsRXFCOUqvWxCX2kMo=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=w3vIf3ykYPm9ybX+f6ylxmeieFbyWls56GHy1zFJpcRjrv+kh3mlf1c0iRjEEWnEi QUDTBZvmtmaci4qmEpnhKM7o3d3a5sxKcCQevTarM2pjl2R/XK1glfrHunN1Caz4KS RBnKUovBSOozARd6BexjqaEbzU9+zKvQtL9hW6VU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 8F85C3858D3C for ; Wed, 1 Mar 2023 09:11:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8F85C3858D3C 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-625-7Iw428B4PIWD24YZmjxJqA-1; Wed, 01 Mar 2023 04:11:43 -0500 X-MC-Unique: 7Iw428B4PIWD24YZmjxJqA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C1D55858F09; Wed, 1 Mar 2023 09:11:42 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 85B702166B26; Wed, 1 Mar 2023 09:11:42 +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 3219BdpL1620787 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 1 Mar 2023 10:11:40 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3219BdQQ1620786; Wed, 1 Mar 2023 10:11:39 +0100 Date: Wed, 1 Mar 2023 10:11:38 +0100 To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] cfgexpand: Handle WIDEN_{PLUS,MINUS}_EXPR and VEC_WIDEN_{PLUS,MINUS}_{HI,LO}_EXPR in expand_debug_expr [PR108967] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi! When these tree codes were introduced, expand_debug_expr hasn't been updated to handle them. For the VEC_*_EXPR we currently mostly punt, the non-vector ones can be handled easily. In release compilers this doesn't ICE, but with checking we ICE so that we make sure to handle all the needed tree codes there. Bootstrapped/regtested on x86_64-linux and i686-linux, additionally tested on the testcase with cross to aarch64-linux, ok for trunk? 2023-03-01 Jakub Jelinek PR debug/108967 * cfgexpand.cc (expand_debug_expr): Handle WIDEN_{PLUS,MINUS}_EXPR and VEC_WIDEN_{PLUS,MINUS}_{HI,LO}_EXPR. * g++.dg/debug/pr108967.C: New test. Jakub --- gcc/cfgexpand.cc.jj 2023-02-21 11:44:48.479464567 +0100 +++ gcc/cfgexpand.cc 2023-02-28 16:21:45.068784055 +0100 @@ -5365,6 +5365,10 @@ expand_debug_expr (tree exp) case VEC_WIDEN_MULT_ODD_EXPR: case VEC_WIDEN_LSHIFT_HI_EXPR: case VEC_WIDEN_LSHIFT_LO_EXPR: + case VEC_WIDEN_PLUS_HI_EXPR: + case VEC_WIDEN_PLUS_LO_EXPR: + case VEC_WIDEN_MINUS_HI_EXPR: + case VEC_WIDEN_MINUS_LO_EXPR: case VEC_PERM_EXPR: case VEC_DUPLICATE_EXPR: case VEC_SERIES_EXPR: @@ -5401,6 +5405,8 @@ expand_debug_expr (tree exp) case WIDEN_MULT_EXPR: case WIDEN_MULT_PLUS_EXPR: case WIDEN_MULT_MINUS_EXPR: + case WIDEN_PLUS_EXPR: + case WIDEN_MINUS_EXPR: if (SCALAR_INT_MODE_P (GET_MODE (op0)) && SCALAR_INT_MODE_P (mode)) { @@ -5413,6 +5419,10 @@ expand_debug_expr (tree exp) op1 = simplify_gen_unary (ZERO_EXTEND, mode, op1, inner_mode); else op1 = simplify_gen_unary (SIGN_EXTEND, mode, op1, inner_mode); + if (TREE_CODE (exp) == WIDEN_PLUS_EXPR) + return simplify_gen_binary (PLUS, mode, op0, op1); + else if (TREE_CODE (exp) == WIDEN_MINUS_EXPR) + return simplify_gen_binary (MINUS, mode, op0, op1); op0 = simplify_gen_binary (MULT, mode, op0, op1); if (TREE_CODE (exp) == WIDEN_MULT_EXPR) return op0; --- gcc/testsuite/g++.dg/debug/pr108967.C.jj 2023-02-28 17:27:27.922636974 +0100 +++ gcc/testsuite/g++.dg/debug/pr108967.C 2023-02-28 17:27:20.571741186 +0100 @@ -0,0 +1,41 @@ +// PR debug/108967 +// { dg-do compile } + +struct F { unsigned short r[8]; }; +extern void foo (F); + +static inline F +bar (F a, F b) +{ + for (int i = 0; i < 8; ++i) + a.r[i] = a.r[i] + b.r[i] < (unsigned short) -1 ? a.r[i] + b.r[i] : (unsigned short) -1; + return a; +} + +static inline void +baz (F v) +{ + foo (v); +} + +void +qux (F a, F b) +{ + F c = bar (a, b); + baz (c); +} + +static inline F +corge (F a, F b) +{ + for (int i = 0; i < 8; ++i) + a.r[i] = a.r[i] - b.r[i] > 0 ? a.r[i] - b.r[i] : 0; + return a; +} + +void +garply (F a, F b) +{ + F c = corge (a, b); + baz (c); +}