From patchwork Tue Sep 1 17:00:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Bergner X-Patchwork-Id: 1355275 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=NPV5vVkc; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bgtcx5KY5zB3sy for ; Wed, 2 Sep 2020 03:01:04 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B84613870890; Tue, 1 Sep 2020 17:01:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B84613870890 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1598979660; bh=G9tEehzdI/kNxzEbz7pcWl3BJM5t58iwVEdA5c2tpGY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=NPV5vVkcZhRszuP+OY/j7K2xhF1W/KQQL7ZAfzMJ6CBK+olSGrpdDpN8h95qTAt/B 76K75XG7uGxCg/CCFPUswfih4VKa+b5ERhTjDQBgfBI4slCNJyFU3L4KlCQbU6zzy/ aEwup6iPfyPrZQcJ1YtJ6aAWqGx2r31mOIVO3Ntk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id B524C385782F for ; Tue, 1 Sep 2020 17:00:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B524C385782F Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 081Go6ee030011; Tue, 1 Sep 2020 13:00:56 -0400 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com with ESMTP id 339t5y87c1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 01 Sep 2020 13:00:54 -0400 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 081Gw0g0027732; Tue, 1 Sep 2020 17:00:52 GMT Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma03dal.us.ibm.com with ESMTP id 337en97x39-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 01 Sep 2020 17:00:52 +0000 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 081H0pJb29819204 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 1 Sep 2020 17:00:51 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 51B5DAE05C; Tue, 1 Sep 2020 17:00:51 +0000 (GMT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A36DEAE05F; Tue, 1 Sep 2020 17:00:50 +0000 (GMT) Received: from [9.163.68.76] (unknown [9.163.68.76]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 1 Sep 2020 17:00:50 +0000 (GMT) To: Segher Boessenkool Subject: [PATCH] rs6000: MMA built-in dies with incorrect sharing of tree nodes error Message-ID: <990a956d-77cc-368d-f9fc-61cfac3facd4@linux.ibm.com> Date: Tue, 1 Sep 2020 12:00:50 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 Content-Language: en-US X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-09-01_10:2020-09-01, 2020-09-01 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 adultscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 spamscore=0 suspectscore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009010133 X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Peter Bergner via Gcc-patches From: Peter Bergner Reply-To: Peter Bergner Cc: Bill Schmidt , GCC Patches Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" When we expand our MMA built-ins into gimple, we (me!) erroneously reused the accumulator memory reference for both the source input value as well as the destination output value. This led to a tree sharing error. The solution is to create separate memory references for the input and output values. I'll note that the old build1 call is not actually needed. I believe I started using that first and then noticed that didn't work in call cases, so I used build_simple_mem_ref in the other cases. I should have noticed that build_simple_mem_ref worked for all cases. :-) This passed bootstrap and regtesting on powerpc64le-linux with no regressions. Raji has also done some runtime testing of her MMA tests using this patch and they all showed no regressions either. Ok for trunk and GCC 10 after a couple of days of burn in? Peter gcc/ PR target/96808 * config/rs6000/rs6000-call.c (rs6000_gimple_fold_mma_builtin): Do not reuse accumulator memory reference for source and destination accesses. gcc/testsuite/ PR target/96808 * gcc.target/powerpc/pr96808.c: New test. diff --git a/gcc/config/rs6000/rs6000-call.c b/gcc/config/rs6000/rs6000-call.c index 26388762c5f..b6b45687aae 100644 --- a/gcc/config/rs6000/rs6000-call.c +++ b/gcc/config/rs6000/rs6000-call.c @@ -11471,12 +11471,8 @@ rs6000_gimple_fold_mma_builtin (gimple_stmt_iterator *gsi) /* Convert this built-in into an internal version that uses pass-by-value arguments. The internal built-in follows immediately after this one. */ new_decl = rs6000_builtin_decls[fncode + 1]; - tree lhs, mem, op[MAX_MMA_OPERANDS]; + tree lhs, op[MAX_MMA_OPERANDS]; tree acc = gimple_call_arg (stmt, 0); - if (TREE_CODE (acc) == PARM_DECL) - mem = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (acc)), acc); - else - mem = build_simple_mem_ref (acc); push_gimplify_context (true); if ((attr & RS6000_BTC_QUAD) != 0) @@ -11486,7 +11482,7 @@ rs6000_gimple_fold_mma_builtin (gimple_stmt_iterator *gsi) op[0] = make_ssa_name (vector_quad_type_node); for (unsigned i = 1; i < nopnds; i++) op[i] = gimple_call_arg (stmt, i); - gimplify_assign (op[0], mem, &new_seq); + gimplify_assign (op[0], build_simple_mem_ref (acc), &new_seq); } else { @@ -11536,7 +11532,7 @@ rs6000_gimple_fold_mma_builtin (gimple_stmt_iterator *gsi) lhs = make_ssa_name (vector_quad_type_node); gimple_call_set_lhs (new_call, lhs); gimple_seq_add_stmt (&new_seq, new_call); - gimplify_assign (mem, lhs, &new_seq); + gimplify_assign (build_simple_mem_ref (acc), lhs, &new_seq); pop_gimplify_context (NULL); gsi_replace_with_seq (gsi, new_seq, true); diff --git a/gcc/testsuite/gcc.target/powerpc/pr96808.c b/gcc/testsuite/gcc.target/powerpc/pr96808.c new file mode 100644 index 00000000000..2d44bd51b20 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr96808.c @@ -0,0 +1,59 @@ +/* PR target/96808 */ +/* { dg-do compile } */ +/* { dg-require-effective-target power10_ok } */ +/* { dg-options "-O2 -mdejagnu-cpu=power10" } */ + +/* Verify we do not ICE on the tests below. */ + +void +old_ok (__vector_quad *dst, vector unsigned char vc) +{ + __vector_quad vq; + __builtin_mma_xxsetaccz(&vq); + __builtin_mma_xvf32gerpp(&vq, vc, vc); + *dst = vq; +} + +void +test0 (__vector_quad *dst, vector unsigned char vc) +{ + __vector_quad vq[2]; + __builtin_mma_xxsetaccz(&vq[1]); + __builtin_mma_xvf32gerpp(&vq[1], vc, vc); + *dst = vq[1]; +} + +void +test1 (__vector_quad *dst, vector unsigned char vc) +{ + __vector_quad vq[2][2]; + __builtin_mma_xxsetaccz(&vq[1][1]); + __builtin_mma_xvf32gerpp(&vq[1][1], vc, vc); + *dst = vq[1][1]; +} + +void +test2 (__vector_quad *dst, vector unsigned char vc) +{ + struct { + __vector_quad dummy; + __vector_quad acc; + } vq; + __builtin_mma_xxsetaccz(&vq.acc); + __builtin_mma_xvf32gerpp(&vq.acc, vc, vc); + *dst = vq.acc; +} + +void +test3 (__vector_quad *dst, vector unsigned char vc) +{ + __builtin_mma_xxsetaccz(&dst[1]); + __builtin_mma_xvf32gerpp(&dst[1], vc, vc); +} + +void +test4 (__vector_quad *dst[], vector unsigned char vc) +{ + __builtin_mma_xxsetaccz(&dst[1][2]); + __builtin_mma_xvf32gerpp(&dst[1][2], vc, vc); +}