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: 62797 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3522829wrd; Wed, 1 Mar 2023 01:12:43 -0800 (PST) X-Google-Smtp-Source: AK7set/BReqmyS6XlVC7uIG+pJ5Ai+mTeICgmBxkr8d2zwzd9p9AhZobUW3uGUCAgMaEFIHua60e X-Received: by 2002:a17:906:f6d0:b0:8aa:6e27:103b with SMTP id jo16-20020a170906f6d000b008aa6e27103bmr5493929ejb.67.1677661963573; Wed, 01 Mar 2023 01:12:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677661963; cv=none; d=google.com; s=arc-20160816; b=jPSv62+fmix8TmFhhAriqMm5bDScvapKPB0LvC8+L/WNr6nAkS4kLKuLx7QIZCky7E vfMJWoo3AavGLo3dYod0qQ6KRIgBIFjSoSD4wVvD83J/1jDJbyYEyUmEJFwPt8lkJ1gZ ZKGrj8Wiyp/pia8pZ1xzVpvwGZrE7kuhXAVt+H7C/OEw50p53YWvw8ImrmUl+LP4cqj9 yA52dFTvdSPc7kawRCKELabGFQOPzm/0OSn/wZXDqOL9TTpTeFbH3yfUVVpQUidhADmx FGc7fAkAX6qHgFGxAv2hCkYtvchtNcM6oosa/OxxLK8/cML95gkUivRTQRC+Igx3ciGc t3gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=WQ6ndaDa43YHXO7gz4cNsbR+pEsRXFCOUqvWxCX2kMo=; b=cdhPzX5FMdGx/QfTP96+/GgGE28+43N4gXSCLpqS2K57Mp9l43kEowX+AunmDHTOE/ MPuCx41nuuTWWi+2/7vHHEJ7d32KzLMK9XO+Lkxl0CeFZY0t2qjGZDYKwuqB2mNndsaY rDh8mctZYudo9y5lRFPa/MZ4Yvxt+LzEoAkLzTtswL5ptCn6eUOssAQh+b1by9aXTwHR ZDRaUrgPUAPKfQhQlhXL2LLxFuYxgu/FrGV4KblJyls7kICjPygp0F8UCGfRjw1NtUHP CBOBaeVyyNNM0cBZ0K/WTJA0p4ttfYXAhL208CnSgLHUeuXOXOM05eOvRokM6uuTL1Tx gxwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=c5tkPAr0; 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=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id a4-20020a170906684400b008e65505a1ebsi14261514ejs.0.2023.03.01.01.12.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Mar 2023 01:12:43 -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=@gcc.gnu.org header.s=default header.b=c5tkPAr0; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 117C23858408 for ; Wed, 1 Mar 2023 09:12:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 117C23858408 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677661956; 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=c5tkPAr0Gv5MgmKzl58Fd4FoXWbEJChPo+Ac+J88aD2uJAOQXs3AyHH4StoY3vWaU PUGuQoti6rpMAkE8ArxoJC5BKg1u5nL9+O8LLAENDvCiXa9aQnmDuzwSykVnnWbmxT CwSgaKdMtbHyykbDhN0uBuwM/p847T1XICqNBVrg= 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759156071055039901?= X-GMAIL-MSGID: =?utf-8?q?1759156071055039901?= 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); +}