Message ID | ecc8d7a3-3c2d-a974-c2cf-034e7fd4136a@linux.ibm.com |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> 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 BC812385841D for <patchwork@sourceware.org>; Mon, 25 Oct 2021 03:04:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BC812385841D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635131089; bh=5+31lyPzk5W9bjCuFNqc5+arzdrkzlcBcRD31BjUHz4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=awWdh+JAcoZPKyYiTrchW3q8S8p2Yf6dXiQ4vV6WyeeNhpK55+udvM34K5d5WPvj6 1quR53VqdfhE2Y4kVVUlaTnw+7cLKRUT7TlGry4+/5O5vJ2Ee7F3qvxVDZv5Pwe5yG TbSHTmbXhOfywmsVOi3qHKVG/tzd/uOPYKKFoLYE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 4F96B3858C27 for <gcc-patches@gcc.gnu.org>; Mon, 25 Oct 2021 03:04:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4F96B3858C27 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19ONgXcx012326; Sun, 24 Oct 2021 23:04:18 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3bvycgy8bk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 24 Oct 2021 23:04:18 -0400 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 19P318wG022362; Sun, 24 Oct 2021 23:04:17 -0400 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 3bvycgy8b6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 24 Oct 2021 23:04:17 -0400 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 19P2wrlG022672; Mon, 25 Oct 2021 03:04:15 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma03ams.nl.ibm.com with ESMTP id 3bva19h2gb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Oct 2021 03:04:15 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 19P34CVl48103790 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 25 Oct 2021 03:04:12 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C22A811C052; Mon, 25 Oct 2021 03:04:12 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7CE1911C050; Mon, 25 Oct 2021 03:04:11 +0000 (GMT) Received: from kewenlins-mbp.cn.ibm.com (unknown [9.200.146.131]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 25 Oct 2021 03:04:11 +0000 (GMT) To: GCC Patches <gcc-patches@gcc.gnu.org> Subject: [PATCH] rs6000: Fix ICE of vect cost related to V1TI [PR102767] Message-ID: <ecc8d7a3-3c2d-a974-c2cf-034e7fd4136a@linux.ibm.com> Date: Mon, 25 Oct 2021 11:04:08 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 Content-Type: text/plain; charset=gbk Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: vHtIk9nUfeCDvHkJG7P0GegZSYg5YUYP X-Proofpoint-GUID: ptZ8ziKnxgi3z-TiCvQd75GQmXR9YMqc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-25_01,2021-10-25_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 mlxlogscore=999 suspectscore=0 clxscore=1015 priorityscore=1501 spamscore=0 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110250018 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: "Kewen.Lin via Gcc-patches" <gcc-patches@gcc.gnu.org> Reply-To: "Kewen.Lin" <linkw@linux.ibm.com> Cc: Bill Schmidt <wschmidt@linux.ibm.com>, David Edelsohn <dje.gcc@gmail.com>, Segher Boessenkool <segher@kernel.crashing.org> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
rs6000: Fix ICE of vect cost related to V1TI [PR102767]
|
|
Commit Message
Kewen.Lin
Oct. 25, 2021, 3:04 a.m. UTC
Hi, As PR102767 shows, the commit r12-3482 exposed one ICE in function rs6000_builtin_vectorization_cost. We claims V1TI supports movmisalign on rs6000 (See define_expand "movmisalign<mode>"), so it return true in rs6000_builtin_support_vector_misalignment for misalign 8. Later in the cost querying rs6000_builtin_vectorization_cost, we don't have the arms to handle the V1TI input under (TARGET_VSX && TARGET_ALLOW_MOVMISALIGN). The proposed fix is to add the consideration for V1TI, simply make it as the cost for doubleword which is apparently bigger than the cost of scalar, won't have the vectorization to happen, just to keep consistency and avoid ICE. Another thought is to not support movmisalign for V1TI, but it sounds like a bad idea since it doesn't match the reality. Bootstrapped and regtested on powerpc64le-linux-gnu P9 and powerpc64-linux-gnu P8. Is it ok for trunk? BR, Kewen ----- gcc/ChangeLog: PR target/102767 * config/rs6000/rs6000.c (rs6000_builtin_vectorization_cost): Consider V1T1 mode for unaligned load and store. gcc/testsuite/ChangeLog: PR target/102767 * gcc.target/powerpc/ppc-fortran/pr102767.f90: New file.
Comments
On Sun, Oct 24, 2021 at 11:04 PM Kewen.Lin <linkw@linux.ibm.com> wrote: > > Hi, > > As PR102767 shows, the commit r12-3482 exposed one ICE in function > rs6000_builtin_vectorization_cost. We claims V1TI supports movmisalign > on rs6000 (See define_expand "movmisalign<mode>"), so it return true in > rs6000_builtin_support_vector_misalignment for misalign 8. Later in > the cost querying rs6000_builtin_vectorization_cost, we don't have > the arms to handle the V1TI input under (TARGET_VSX && > TARGET_ALLOW_MOVMISALIGN). > > The proposed fix is to add the consideration for V1TI, simply make it > as the cost for doubleword which is apparently bigger than the cost of > scalar, won't have the vectorization to happen, just to keep consistency > and avoid ICE. Another thought is to not support movmisalign for V1TI, > but it sounds like a bad idea since it doesn't match the reality. > > Bootstrapped and regtested on powerpc64le-linux-gnu P9 and > powerpc64-linux-gnu P8. > > Is it ok for trunk? > > BR, > Kewen > ----- > gcc/ChangeLog: > > PR target/102767 > * config/rs6000/rs6000.c (rs6000_builtin_vectorization_cost): Consider > V1T1 mode for unaligned load and store. > > gcc/testsuite/ChangeLog: > > PR target/102767 > * gcc.target/powerpc/ppc-fortran/pr102767.f90: New file. > > diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c > index b7ea1483da5..73d3e06c3fc 100644 > --- a/gcc/config/rs6000/rs6000.c > +++ b/gcc/config/rs6000/rs6000.c > @@ -5145,7 +5145,8 @@ rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost, > if (TARGET_VSX && TARGET_ALLOW_MOVMISALIGN) > { > elements = TYPE_VECTOR_SUBPARTS (vectype); > - if (elements == 2) > + /* See PR102767, consider V1TI to keep consistency. */ > + if (elements == 2 || elements == 1) > /* Double word aligned. */ > return 4; > > @@ -5184,10 +5185,11 @@ rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost, > > if (TARGET_VSX && TARGET_ALLOW_MOVMISALIGN) > { > - elements = TYPE_VECTOR_SUBPARTS (vectype); > - if (elements == 2) > - /* Double word aligned. */ > - return 2; > + elements = TYPE_VECTOR_SUBPARTS (vectype); > + /* See PR102767, consider V1TI to keep consistency. */ > + if (elements == 2 || elements == 1) > + /* Double word aligned. */ > + return 2; This section of the patch incorrectly changes the indentation. Please use the correct indentation. > > if (elements == 4) > { > diff --git a/gcc/testsuite/gcc.target/powerpc/ppc-fortran/pr102767.f90 b/gcc/testsuite/gcc.target/powerpc/ppc-fortran/pr102767.f90 > new file mode 100644 > index 00000000000..a4122482989 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/powerpc/ppc-fortran/pr102767.f90 > @@ -0,0 +1,21 @@ > +! { dg-require-effective-target powerpc_vsx_ok } > +! { dg-options "-mvsx -O2 -ftree-vectorize -mno-efficient-unaligned-vsx" } > + > +INTERFACE > + FUNCTION elemental_mult (a, b, c) > + type(*), DIMENSION(..) :: a, b, c > + END > +END INTERFACE > + > +allocatable z > +integer, dimension(2,2) :: a, b > +call test_CFI_address > +contains > + subroutine test_CFI_address > + if (elemental_mult (z, x, y) .ne. 0) stop > + a = reshape ([4,3,2,1], [2,2]) > + b = reshape ([2,3,4,5], [2,2]) > + if (elemental_mult (i, a, b) .ne. 0) stop > + end > +end > + > The patch is okay with the indentation correction. Thanks, David
Hi David, Thanks for the review! on 2021/10/27 下午9:12, David Edelsohn wrote: > On Sun, Oct 24, 2021 at 11:04 PM Kewen.Lin <linkw@linux.ibm.com> wrote: >> >> Hi, >> >> As PR102767 shows, the commit r12-3482 exposed one ICE in function >> rs6000_builtin_vectorization_cost. We claims V1TI supports movmisalign >> on rs6000 (See define_expand "movmisalign<mode>"), so it return true in >> rs6000_builtin_support_vector_misalignment for misalign 8. Later in >> the cost querying rs6000_builtin_vectorization_cost, we don't have >> the arms to handle the V1TI input under (TARGET_VSX && >> TARGET_ALLOW_MOVMISALIGN). >> >> The proposed fix is to add the consideration for V1TI, simply make it >> as the cost for doubleword which is apparently bigger than the cost of >> scalar, won't have the vectorization to happen, just to keep consistency >> and avoid ICE. Another thought is to not support movmisalign for V1TI, >> but it sounds like a bad idea since it doesn't match the reality. >> >> Bootstrapped and regtested on powerpc64le-linux-gnu P9 and >> powerpc64-linux-gnu P8. >> >> Is it ok for trunk? >> >> BR, >> Kewen >> ----- >> gcc/ChangeLog: >> >> PR target/102767 >> * config/rs6000/rs6000.c (rs6000_builtin_vectorization_cost): Consider >> V1T1 mode for unaligned load and store. >> >> gcc/testsuite/ChangeLog: >> >> PR target/102767 >> * gcc.target/powerpc/ppc-fortran/pr102767.f90: New file. >> >> diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c >> index b7ea1483da5..73d3e06c3fc 100644 >> --- a/gcc/config/rs6000/rs6000.c >> +++ b/gcc/config/rs6000/rs6000.c >> @@ -5145,7 +5145,8 @@ rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost, >> if (TARGET_VSX && TARGET_ALLOW_MOVMISALIGN) >> { >> elements = TYPE_VECTOR_SUBPARTS (vectype); >> - if (elements == 2) >> + /* See PR102767, consider V1TI to keep consistency. */ >> + if (elements == 2 || elements == 1) >> /* Double word aligned. */ >> return 4; >> >> @@ -5184,10 +5185,11 @@ rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost, >> >> if (TARGET_VSX && TARGET_ALLOW_MOVMISALIGN) >> { >> - elements = TYPE_VECTOR_SUBPARTS (vectype); >> - if (elements == 2) >> - /* Double word aligned. */ >> - return 2; >> + elements = TYPE_VECTOR_SUBPARTS (vectype); >> + /* See PR102767, consider V1TI to keep consistency. */ >> + if (elements == 2 || elements == 1) >> + /* Double word aligned. */ >> + return 2; > > This section of the patch incorrectly changes the indentation. Please > use the correct indentation. > The indentation change is intentional since the original identation is wrong (more than 8 spaces leading the lines), there are more wrong identation lines above the first changed line, but I thought it seems a bad idea to fix them too when they are unrelated to what this patch wants to fix, so I left them alone. With the above clarification, may I push this patch without any updates for the mentioned indentation issue? >> >> if (elements == 4) >> { >> diff --git a/gcc/testsuite/gcc.target/powerpc/ppc-fortran/pr102767.f90 b/gcc/testsuite/gcc.target/powerpc/ppc-fortran/pr102767.f90 >> new file mode 100644 >> index 00000000000..a4122482989 >> --- /dev/null >> +++ b/gcc/testsuite/gcc.target/powerpc/ppc-fortran/pr102767.f90 >> @@ -0,0 +1,21 @@ >> +! { dg-require-effective-target powerpc_vsx_ok } >> +! { dg-options "-mvsx -O2 -ftree-vectorize -mno-efficient-unaligned-vsx" } >> + >> +INTERFACE >> + FUNCTION elemental_mult (a, b, c) >> + type(*), DIMENSION(..) :: a, b, c >> + END >> +END INTERFACE >> + >> +allocatable z >> +integer, dimension(2,2) :: a, b >> +call test_CFI_address >> +contains >> + subroutine test_CFI_address >> + if (elemental_mult (z, x, y) .ne. 0) stop >> + a = reshape ([4,3,2,1], [2,2]) >> + b = reshape ([2,3,4,5], [2,2]) >> + if (elemental_mult (i, a, b) .ne. 0) stop >> + end >> +end >> + >> > > The patch is okay with the indentation correction. > > Thanks, David > Thanks! BR, Kewen
On Wed, Oct 27, 2021 at 9:30 PM Kewen.Lin <linkw@linux.ibm.com> wrote: > > Hi David, > > Thanks for the review! > > on 2021/10/27 下午9:12, David Edelsohn wrote: > > On Sun, Oct 24, 2021 at 11:04 PM Kewen.Lin <linkw@linux.ibm.com> wrote: > >> > >> Hi, > >> > >> As PR102767 shows, the commit r12-3482 exposed one ICE in function > >> rs6000_builtin_vectorization_cost. We claims V1TI supports movmisalign > >> on rs6000 (See define_expand "movmisalign<mode>"), so it return true in > >> rs6000_builtin_support_vector_misalignment for misalign 8. Later in > >> the cost querying rs6000_builtin_vectorization_cost, we don't have > >> the arms to handle the V1TI input under (TARGET_VSX && > >> TARGET_ALLOW_MOVMISALIGN). > >> > >> The proposed fix is to add the consideration for V1TI, simply make it > >> as the cost for doubleword which is apparently bigger than the cost of > >> scalar, won't have the vectorization to happen, just to keep consistency > >> and avoid ICE. Another thought is to not support movmisalign for V1TI, > >> but it sounds like a bad idea since it doesn't match the reality. > >> > >> Bootstrapped and regtested on powerpc64le-linux-gnu P9 and > >> powerpc64-linux-gnu P8. > >> > >> Is it ok for trunk? > >> > >> BR, > >> Kewen > >> ----- > >> gcc/ChangeLog: > >> > >> PR target/102767 > >> * config/rs6000/rs6000.c (rs6000_builtin_vectorization_cost): Consider > >> V1T1 mode for unaligned load and store. > >> > >> gcc/testsuite/ChangeLog: > >> > >> PR target/102767 > >> * gcc.target/powerpc/ppc-fortran/pr102767.f90: New file. > >> > >> diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c > >> index b7ea1483da5..73d3e06c3fc 100644 > >> --- a/gcc/config/rs6000/rs6000.c > >> +++ b/gcc/config/rs6000/rs6000.c > >> @@ -5145,7 +5145,8 @@ rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost, > >> if (TARGET_VSX && TARGET_ALLOW_MOVMISALIGN) > >> { > >> elements = TYPE_VECTOR_SUBPARTS (vectype); > >> - if (elements == 2) > >> + /* See PR102767, consider V1TI to keep consistency. */ > >> + if (elements == 2 || elements == 1) > >> /* Double word aligned. */ > >> return 4; > >> > >> @@ -5184,10 +5185,11 @@ rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost, > >> > >> if (TARGET_VSX && TARGET_ALLOW_MOVMISALIGN) > >> { > >> - elements = TYPE_VECTOR_SUBPARTS (vectype); > >> - if (elements == 2) > >> - /* Double word aligned. */ > >> - return 2; > >> + elements = TYPE_VECTOR_SUBPARTS (vectype); > >> + /* See PR102767, consider V1TI to keep consistency. */ > >> + if (elements == 2 || elements == 1) > >> + /* Double word aligned. */ > >> + return 2; > > > > This section of the patch incorrectly changes the indentation. Please > > use the correct indentation. > > > > The indentation change is intentional since the original identation is > wrong (more than 8 spaces leading the lines), there are more wrong > identation lines above the first changed line, but I thought it seems a > bad idea to fix them too when they are unrelated to what this patch > wants to fix, so I left them alone. > > With the above clarification, may I push this patch without any updates > for the mentioned indentation issue? If you correct the indentation, you should adjust it for the entire block, not just the lines that you change. If you want to fix the entire block to TAB+spaces as well, okay. You didn't mention that you were fixing the indentation in the explanation of the patch. Thank, David > > >> > >> if (elements == 4) > >> { > >> diff --git a/gcc/testsuite/gcc.target/powerpc/ppc-fortran/pr102767.f90 b/gcc/testsuite/gcc.target/powerpc/ppc-fortran/pr102767.f90 > >> new file mode 100644 > >> index 00000000000..a4122482989 > >> --- /dev/null > >> +++ b/gcc/testsuite/gcc.target/powerpc/ppc-fortran/pr102767.f90 > >> @@ -0,0 +1,21 @@ > >> +! { dg-require-effective-target powerpc_vsx_ok } > >> +! { dg-options "-mvsx -O2 -ftree-vectorize -mno-efficient-unaligned-vsx" } > >> + > >> +INTERFACE > >> + FUNCTION elemental_mult (a, b, c) > >> + type(*), DIMENSION(..) :: a, b, c > >> + END > >> +END INTERFACE > >> + > >> +allocatable z > >> +integer, dimension(2,2) :: a, b > >> +call test_CFI_address > >> +contains > >> + subroutine test_CFI_address > >> + if (elemental_mult (z, x, y) .ne. 0) stop > >> + a = reshape ([4,3,2,1], [2,2]) > >> + b = reshape ([2,3,4,5], [2,2]) > >> + if (elemental_mult (i, a, b) .ne. 0) stop > >> + end > >> +end > >> + > >> > > > > The patch is okay with the indentation correction. > > > > Thanks, David > > > > Thanks! > > BR, > Kewen
on 2021/10/28 上午9:43, David Edelsohn wrote: > On Wed, Oct 27, 2021 at 9:30 PM Kewen.Lin <linkw@linux.ibm.com> wrote: >> >> Hi David, >> >> Thanks for the review! >> >> on 2021/10/27 下午9:12, David Edelsohn wrote: >>> On Sun, Oct 24, 2021 at 11:04 PM Kewen.Lin <linkw@linux.ibm.com> wrote: >>>> >>>> Hi, >>>> >>>> As PR102767 shows, the commit r12-3482 exposed one ICE in function >>>> rs6000_builtin_vectorization_cost. We claims V1TI supports movmisalign >>>> on rs6000 (See define_expand "movmisalign<mode>"), so it return true in >>>> rs6000_builtin_support_vector_misalignment for misalign 8. Later in >>>> the cost querying rs6000_builtin_vectorization_cost, we don't have >>>> the arms to handle the V1TI input under (TARGET_VSX && >>>> TARGET_ALLOW_MOVMISALIGN). >>>> >>>> The proposed fix is to add the consideration for V1TI, simply make it >>>> as the cost for doubleword which is apparently bigger than the cost of >>>> scalar, won't have the vectorization to happen, just to keep consistency >>>> and avoid ICE. Another thought is to not support movmisalign for V1TI, >>>> but it sounds like a bad idea since it doesn't match the reality. >>>> >>>> Bootstrapped and regtested on powerpc64le-linux-gnu P9 and >>>> powerpc64-linux-gnu P8. >>>> >>>> Is it ok for trunk? >>>> >>>> BR, >>>> Kewen >>>> ----- >>>> gcc/ChangeLog: >>>> >>>> PR target/102767 >>>> * config/rs6000/rs6000.c (rs6000_builtin_vectorization_cost): Consider >>>> V1T1 mode for unaligned load and store. >>>> >>>> gcc/testsuite/ChangeLog: >>>> >>>> PR target/102767 >>>> * gcc.target/powerpc/ppc-fortran/pr102767.f90: New file. >>>> >>>> diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c >>>> index b7ea1483da5..73d3e06c3fc 100644 >>>> --- a/gcc/config/rs6000/rs6000.c >>>> +++ b/gcc/config/rs6000/rs6000.c >>>> @@ -5145,7 +5145,8 @@ rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost, >>>> if (TARGET_VSX && TARGET_ALLOW_MOVMISALIGN) >>>> { >>>> elements = TYPE_VECTOR_SUBPARTS (vectype); >>>> - if (elements == 2) >>>> + /* See PR102767, consider V1TI to keep consistency. */ >>>> + if (elements == 2 || elements == 1) >>>> /* Double word aligned. */ >>>> return 4; >>>> >>>> @@ -5184,10 +5185,11 @@ rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost, >>>> >>>> if (TARGET_VSX && TARGET_ALLOW_MOVMISALIGN) >>>> { >>>> - elements = TYPE_VECTOR_SUBPARTS (vectype); >>>> - if (elements == 2) >>>> - /* Double word aligned. */ >>>> - return 2; >>>> + elements = TYPE_VECTOR_SUBPARTS (vectype); >>>> + /* See PR102767, consider V1TI to keep consistency. */ >>>> + if (elements == 2 || elements == 1) >>>> + /* Double word aligned. */ >>>> + return 2; >>> >>> This section of the patch incorrectly changes the indentation. Please >>> use the correct indentation. >>> >> >> The indentation change is intentional since the original identation is >> wrong (more than 8 spaces leading the lines), there are more wrong >> identation lines above the first changed line, but I thought it seems a >> bad idea to fix them too when they are unrelated to what this patch >> wants to fix, so I left them alone. >> >> With the above clarification, may I push this patch without any updates >> for the mentioned indentation issue? > > If you correct the indentation, you should adjust it for the entire > block, not just the lines that you change. If you want to fix the > entire block to TAB+spaces as well, okay. You didn't mention that you > were fixing the indentation in the explanation of the patch. > Sorry for not mentioning that. Got it, I'll reformat the entire block then, also with additional notes in the commit log. Thanks again. BR, Kewen > Thank, David > >> >>>> >>>> if (elements == 4) >>>> { >>>> diff --git a/gcc/testsuite/gcc.target/powerpc/ppc-fortran/pr102767.f90 b/gcc/testsuite/gcc.target/powerpc/ppc-fortran/pr102767.f90 >>>> new file mode 100644 >>>> index 00000000000..a4122482989 >>>> --- /dev/null >>>> +++ b/gcc/testsuite/gcc.target/powerpc/ppc-fortran/pr102767.f90 >>>> @@ -0,0 +1,21 @@ >>>> +! { dg-require-effective-target powerpc_vsx_ok } >>>> +! { dg-options "-mvsx -O2 -ftree-vectorize -mno-efficient-unaligned-vsx" } >>>> + >>>> +INTERFACE >>>> + FUNCTION elemental_mult (a, b, c) >>>> + type(*), DIMENSION(..) :: a, b, c >>>> + END >>>> +END INTERFACE >>>> + >>>> +allocatable z >>>> +integer, dimension(2,2) :: a, b >>>> +call test_CFI_address >>>> +contains >>>> + subroutine test_CFI_address >>>> + if (elemental_mult (z, x, y) .ne. 0) stop >>>> + a = reshape ([4,3,2,1], [2,2]) >>>> + b = reshape ([2,3,4,5], [2,2]) >>>> + if (elemental_mult (i, a, b) .ne. 0) stop >>>> + end >>>> +end >>>> + >>>> >>> >>> The patch is okay with the indentation correction. >>> >>> Thanks, David >>> >> >> Thanks! >> >> BR, >> Kewen
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index b7ea1483da5..73d3e06c3fc 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -5145,7 +5145,8 @@ rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost, if (TARGET_VSX && TARGET_ALLOW_MOVMISALIGN) { elements = TYPE_VECTOR_SUBPARTS (vectype); - if (elements == 2) + /* See PR102767, consider V1TI to keep consistency. */ + if (elements == 2 || elements == 1) /* Double word aligned. */ return 4; @@ -5184,10 +5185,11 @@ rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost, if (TARGET_VSX && TARGET_ALLOW_MOVMISALIGN) { - elements = TYPE_VECTOR_SUBPARTS (vectype); - if (elements == 2) - /* Double word aligned. */ - return 2; + elements = TYPE_VECTOR_SUBPARTS (vectype); + /* See PR102767, consider V1TI to keep consistency. */ + if (elements == 2 || elements == 1) + /* Double word aligned. */ + return 2; if (elements == 4) { diff --git a/gcc/testsuite/gcc.target/powerpc/ppc-fortran/pr102767.f90 b/gcc/testsuite/gcc.target/powerpc/ppc-fortran/pr102767.f90 new file mode 100644 index 00000000000..a4122482989 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/ppc-fortran/pr102767.f90 @@ -0,0 +1,21 @@ +! { dg-require-effective-target powerpc_vsx_ok } +! { dg-options "-mvsx -O2 -ftree-vectorize -mno-efficient-unaligned-vsx" } + +INTERFACE + FUNCTION elemental_mult (a, b, c) + type(*), DIMENSION(..) :: a, b, c + END +END INTERFACE + +allocatable z +integer, dimension(2,2) :: a, b +call test_CFI_address +contains + subroutine test_CFI_address + if (elemental_mult (z, x, y) .ne. 0) stop + a = reshape ([4,3,2,1], [2,2]) + b = reshape ([2,3,4,5], [2,2]) + if (elemental_mult (i, a, b) .ne. 0) stop + end +end +