From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1464) id 55F64385040B; Fri, 3 Sep 2021 01:48:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 55F64385040B MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Peter Bergner To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-10091] rs6000: Fix ICE expanding lxvp and stxvp gimple built-ins [PR101849] X-Act-Checkin: gcc X-Git-Author: Peter Bergner X-Git-Refname: refs/heads/releases/gcc-10 X-Git-Oldrev: 607a48c05b9fdef82f7841e089694c75c0e68141 X-Git-Newrev: de2114d2f1792beae55dccb512c4c521b934e72b Message-Id: <20210903014857.55F64385040B@sourceware.org> Date: Fri, 3 Sep 2021 01:48:57 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Sep 2021 01:48:57 -0000 https://gcc.gnu.org/g:de2114d2f1792beae55dccb512c4c521b934e72b commit r10-10091-gde2114d2f1792beae55dccb512c4c521b934e72b Author: Peter Bergner Date: Thu Aug 19 17:33:29 2021 -0500 rs6000: Fix ICE expanding lxvp and stxvp gimple built-ins [PR101849] PR101849 shows we ICE on a test case when we pass a non __vector_pair * pointer to the __builtin_vsx_lxvp and __builtin_vsx_stxvp built-ins that is cast to __vector_pair *. The problem is that when we expand the built-in, the cast has already been removed from gimple and we are only given the base pointer. The solution used here (which fixes the ICE) is to catch this case and convert the pointer to a __vector_pair * pointer when expanding the built-in. 2021-08-19 Peter Bergner gcc/ PR target/101849 * config/rs6000/rs6000-call.c (rs6000_gimple_fold_mma_builtin): Cast pointer to __vector_pair *. gcc/testsuite/ PR target/101849 * gcc.target/powerpc/pr101849.c: New test. (cherry picked from commit b0963c4379becafaebd8e52b0b42698ff151c293) Diff: --- gcc/config/rs6000/rs6000-call.c | 6 ++++++ gcc/testsuite/gcc.target/powerpc/pr101849.c | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/gcc/config/rs6000/rs6000-call.c b/gcc/config/rs6000/rs6000-call.c index 60ea20b2dbe..b5e06eb08fd 100644 --- a/gcc/config/rs6000/rs6000-call.c +++ b/gcc/config/rs6000/rs6000-call.c @@ -10912,6 +10912,9 @@ rs6000_gimple_fold_mma_builtin (gimple_stmt_iterator *gsi) tree offset = gimple_call_arg (stmt, 0); tree ptr = gimple_call_arg (stmt, 1); tree lhs = gimple_call_lhs (stmt); + if (TREE_TYPE (TREE_TYPE (ptr)) != vector_pair_type_node) + ptr = build1 (VIEW_CONVERT_EXPR, + build_pointer_type (vector_pair_type_node), ptr); tree mem = build_simple_mem_ref (build2 (POINTER_PLUS_EXPR, TREE_TYPE (ptr), ptr, offset)); gimplify_assign (lhs, mem, &new_seq); @@ -10925,6 +10928,9 @@ rs6000_gimple_fold_mma_builtin (gimple_stmt_iterator *gsi) tree src = gimple_call_arg (stmt, 0); tree offset = gimple_call_arg (stmt, 1); tree ptr = gimple_call_arg (stmt, 2); + if (TREE_TYPE (TREE_TYPE (ptr)) != vector_pair_type_node) + ptr = build1 (VIEW_CONVERT_EXPR, + build_pointer_type (vector_pair_type_node), ptr); tree mem = build_simple_mem_ref (build2 (POINTER_PLUS_EXPR, TREE_TYPE (ptr), ptr, offset)); gimplify_assign (mem, src, &new_seq); diff --git a/gcc/testsuite/gcc.target/powerpc/pr101849.c b/gcc/testsuite/gcc.target/powerpc/pr101849.c new file mode 100644 index 00000000000..823fbfe9647 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr101849.c @@ -0,0 +1,22 @@ +/* PR target/101849 */ +/* { 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 +foo (__vector_pair *dst, double *x, long offset) +{ + dst[0] = __builtin_vsx_lxvp (0, (__vector_pair *)(void *)x); + dst[1] = __builtin_vsx_lxvp (32, (__vector_pair *)(void *)x); + dst[2] = __builtin_vsx_lxvp (offset, (__vector_pair *)(void *)x); +} + +void +bar (__vector_pair *src, double *x, long offset) +{ + __builtin_vsx_stxvp (src[0], 0, (__vector_pair *)(void *)x); + __builtin_vsx_stxvp (src[1], 32, (__vector_pair *)(void *)x); + __builtin_vsx_stxvp (src[2], offset, (__vector_pair *)(void *)x); +}