This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR 91605
- From: Bernd Edlinger <bernd dot edlinger at hotmail dot de>
- To: Richard Biener <rguenther at suse dot de>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Jeff Law <law at redhat dot com>
- Date: Mon, 2 Sep 2019 14:02:10 +0000
- Subject: Re: [PATCH] Fix PR 91605
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tuPE/JhhiQZtks8whY0Nds/ffeFz/YpJA6nq56+lt+Q=; b=LTbjfN/SFYruNG0Pe4AOKkEqDmgTSLPNmmq+89/qB6vH3BVIP/TXjDxxr4y/pXZHZVSwKUSmbsWRuyjtOBe0hzAzB4KXN0ju/XaTa5q2ZQ1I3pb4IlzvYE+K7XEWal32bpLUDo3Kl5mXYwezIbK3ZCMN5GTE4YyRbesNQ1iL24f6K0FtdtxLYBmNt79uL7W+GlNddYK8Idyecn4T4yedfdWzVaTSqyzwodbgT+CH1OnnMUO0sj1HCz5cH5MdX+5DC9aWHXHlSTbdti2xc2Rq4X7UxJHsUU3i/1xmjXdod2mWRgyTeM3YdUv3vS5gJmTotWBVv8pXDLPGjn+YWvAUWQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XmRHIN10PjQDHaM/Did4wp0tIAK3jGMj/DDoiyLCZ4MlX508ncORU+/ua+QW5F/QUbt5w9Hh4pRNmDuZ49TsSWAijCLBGI07JxIaSroaTtKTIukcnQyFE7WOAAgl6q8aMx2ohiGRH6UFrPwOXBuK2A/Ocw3cB+8UuNCU7sbUiICu/Ea1o+3NMLeix8WhZ7JXMahgNMru3rmyvapZqH2iFRQC44pqb8k7rDDxxb488WrrytzU2mSnPRCUe8WHf45kEFqhWmwgcft40ffsrfslW0yEkyN4eusdDYfiYBhGNiUuNGezfQEmt7/4KWy8kblx1/JypZX7M/RhauowPI7dbA==
- References: <AM6PR10MB2566FFE1880C451C49F3DD08E4BF0@AM6PR10MB2566.EURPRD10.PROD.OUTLOOK.COM> <alpine.LSU.2.20.1909020948330.32458@zhemvz.fhfr.qr>
On 9/2/19 9:50 AM, Richard Biener wrote:
> On Sun, 1 Sep 2019, Bernd Edlinger wrote:
>
>> Hi,
>>
>> this fixes an oversight in r274986.
>> We need to avoid using movmisalign on DECL_P which are not in memory,
>> similar to the !mem_ref_refers_to_non_mem_p which unfortunately can't
>> handle DECL_P.
>>
>
> But
>
> - && (DECL_P (to) || !mem_ref_refers_to_non_mem_p (to))
> + && (DECL_P (to) ? MEM_P (DECL_RTL (to))
> + : !mem_ref_refers_to_non_mem_p (to))
>
> and in mem_ref_refers_to_non_mem_p we do
>
> if (!DECL_RTL_SET_P (base))
> return nortl;
>
> return (!MEM_P (DECL_RTL (base)));
>
> so when !DECL_RTL_SET_P (t) we can go full speed ahead? That said,
> can we refactor addr_expr_of_non_mem_decl_p_1 to put
>
Ah, I was not aware that DECL_RTL has a side-effect if !DECL_RTL_SET_P.
> if (TREE_CODE (addr) != ADDR_EXPR)
> return false;
>
> tree base = TREE_OPERAND (addr, 0);
>
> into the single caller and re-use it then also for the DECL_P case?
>
Yes, that is probably better then.
So how about this?
Is it OK?
Thanks
Bernd.
2019-09-01 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR middle-end/91605
* expr.c (addr_expr_of_non_mem_decl_p_1): Refactor into...
(non_mem_decl_p): ...this.
(mem_ref_refers_to_non_mem_p): Handle DECL_P as well ase MEM_REF.
(expand_assignment): Call mem_ref_referes_to_non_mem_p
unconditionally as before.
testsuite:
2019-09-01 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR middle-end/91605
* g++.target/i386/pr91605.C: New test.
Index: gcc/expr.c
===================================================================
--- gcc/expr.c (revision 275279)
+++ gcc/expr.c (working copy)
@@ -4942,18 +4942,13 @@ get_bit_range (poly_uint64_pod *bitstart, poly_uin
*bitend = *bitstart + tree_to_poly_uint64 (DECL_SIZE (repr)) - 1;
}
-/* Returns true if ADDR is an ADDR_EXPR of a DECL that does not reside
- in memory and has non-BLKmode. DECL_RTL must not be a MEM; if
- DECL_RTL was not set yet, return NORTL. */
+/* Returns true if BASE is a DECL that does not reside in memory and
+ has non-BLKmode. DECL_RTL must not be a MEM; if
+ DECL_RTL was not set yet, return false. */
static inline bool
-addr_expr_of_non_mem_decl_p_1 (tree addr, bool nortl)
+non_mem_decl_p (tree base)
{
- if (TREE_CODE (addr) != ADDR_EXPR)
- return false;
-
- tree base = TREE_OPERAND (addr, 0);
-
if (!DECL_P (base)
|| TREE_ADDRESSABLE (base)
|| DECL_MODE (base) == BLKmode)
@@ -4960,19 +4955,33 @@ static inline bool
return false;
if (!DECL_RTL_SET_P (base))
- return nortl;
+ return false;
return (!MEM_P (DECL_RTL (base)));
}
-/* Returns true if the MEM_REF REF refers to an object that does not
+/* Returns true if REF refers to an object that does not
reside in memory and has non-BLKmode. */
static inline bool
mem_ref_refers_to_non_mem_p (tree ref)
{
- tree base = TREE_OPERAND (ref, 0);
- return addr_expr_of_non_mem_decl_p_1 (base, false);
+ tree base;
+
+ if (TREE_CODE (ref) == MEM_REF
+ || TREE_CODE (ref) == TARGET_MEM_REF)
+ {
+ tree addr = TREE_OPERAND (ref, 0);
+
+ if (TREE_CODE (addr) != ADDR_EXPR)
+ return false;
+
+ base = TREE_OPERAND (addr, 0);
+ }
+ else
+ base = ref;
+
+ return non_mem_decl_p (base);
}
/* Expand an assignment that stores the value of FROM into TO. If NONTEMPORAL
@@ -5004,7 +5013,7 @@ expand_assignment (tree to, tree from, bool nontem
|| TREE_CODE (to) == TARGET_MEM_REF
|| DECL_P (to))
&& mode != BLKmode
- && (DECL_P (to) || !mem_ref_refers_to_non_mem_p (to))
+ && !mem_ref_refers_to_non_mem_p (to)
&& ((align = get_object_alignment (to))
< GET_MODE_ALIGNMENT (mode))
&& (((icode = optab_handler (movmisalign_optab, mode))
Index: gcc/testsuite/g++.target/i386/pr91605.C
===================================================================
--- gcc/testsuite/g++.target/i386/pr91605.C (revision 0)
+++ gcc/testsuite/g++.target/i386/pr91605.C (working copy)
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-fpack-struct -mavx" } */
+
+struct A {
+ __attribute__((__vector_size__(4 * sizeof(double)))) double data;
+};
+struct B {
+ A operator*(B);
+};
+void fn1() {
+ B x, y;
+ x *y;
+}