* [PATCH] Fix PR tree-opt/38865 missing FRE with VIEW_CONVERT_EXPR
@ 2009-04-22 21:11 Andrew Pinski
2009-04-23 9:02 ` Richard Guenther
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Pinski @ 2009-04-22 21:11 UTC (permalink / raw)
To: Gcc Patch List
[-- Attachment #1: Type: text/plain, Size: 578 bytes --]
Hi,
The issue here is that we have:
sv_1(D)->i = { 0, 0, 0, 0 };
D.1242_2 = VIEW_CONVERT_EXPR<vector float>(sv_1(D)->i);
And FRE/PRE does not see that it could look through the VCE even
though we could.
This patch allows SCCVN to look through the VCE.
OK? Bootstrapped and tested on i686-linux-gnu with no regressions.
Thanks,
Andrew Pinski
ChangeLog:
* tree-ssa-sccvn.c (visit_reference_op_load): If vn_reference_lookup
is returns NULL and OP is a VCE, look through the VCE.
(visit_reference_op_store): Unwrap the VCE.
* gcc.dg/tree-ssa/fre-vce-1.c: New testcase.
[-- Attachment #2: fixpr38865.diff.txt --]
[-- Type: text/plain, Size: 2064 bytes --]
Index: tree-ssa-sccvn.c
===================================================================
--- tree-ssa-sccvn.c (revision 146612)
+++ tree-ssa-sccvn.c (working copy)
@@ -1700,6 +1700,12 @@
bool changed = false;
tree result = vn_reference_lookup (op, gimple_vuse (stmt), true, NULL);
+ /* If we have a VCE, try looking up its operand as it might be stored in
+ a different type. */
+ if (!result && TREE_CODE (op) == VIEW_CONVERT_EXPR)
+ result = vn_reference_lookup (TREE_OPERAND (op, 0), gimple_vuse (stmt),
+ true, NULL);
+
/* We handle type-punning through unions by value-numbering based
on offset and size of the access. Be prepared to handle a
type-mismatch here via creating a VIEW_CONVERT_EXPR. */
@@ -1793,6 +1799,10 @@
tree result;
bool resultsame = false;
+ /* If the lhs is a VCE, look past it. */
+ if (TREE_CODE (lhs) == VIEW_CONVERT_EXPR)
+ lhs = TREE_OPERAND (lhs, 0);
+
/* First we want to lookup using the *vuses* from the store and see
if there the last store to this location with the same address
had the same value.
Index: testsuite/gcc.dg/tree-ssa/fre-vce-1.c
===================================================================
--- testsuite/gcc.dg/tree-ssa/fre-vce-1.c (revision 0)
+++ testsuite/gcc.dg/tree-ssa/fre-vce-1.c (revision 0)
@@ -0,0 +1,35 @@
+/* { dg-options "-O2 -fdump-tree-fre -w" } */
+/* { dg-do compile } */
+#define vector __attribute__((vector_size(sizeof(int)*4) ))
+struct s { vector int i; };
+vector float f(struct s *sv)
+{
+ sv->i = (vector int){0, 0, 0, 0};
+ return (vector float)sv->i;
+}
+
+
+vector float f1(struct s *sv, vector int a)
+{
+ sv->i = a;
+ return (vector float)sv->i;
+}
+
+struct s1 { int i; };
+
+void g(struct s1 *, float);
+void a1 (struct s1 sv)
+{
+ sv.i = 0;
+ g(&sv, *(float*)&sv.i);
+}
+
+
+void a2 (struct s1 sv, int i)
+{
+ sv.i = i;
+ g(&sv, *(float*)&sv.i);
+}
+
+/* { dg-final { scan-tree-dump-times 2 "fre" "sv_\[0-9\]\\\(D\\\)->i" } } */
+/* { dg-final { scan-tree-dump-times 2 "fre" "sv.i" } } */
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix PR tree-opt/38865 missing FRE with VIEW_CONVERT_EXPR
2009-04-22 21:11 [PATCH] Fix PR tree-opt/38865 missing FRE with VIEW_CONVERT_EXPR Andrew Pinski
@ 2009-04-23 9:02 ` Richard Guenther
0 siblings, 0 replies; 2+ messages in thread
From: Richard Guenther @ 2009-04-23 9:02 UTC (permalink / raw)
To: Andrew Pinski; +Cc: Gcc Patch List
On Wed, Apr 22, 2009 at 10:52 PM, Andrew Pinski <pinskia@gmail.com> wrote:
> Hi,
> The issue here is that we have:
> sv_1(D)->i = { 0, 0, 0, 0 };
> D.1242_2 = VIEW_CONVERT_EXPR<vector float>(sv_1(D)->i);
>
> And FRE/PRE does not see that it could look through the VCE even
> though we could.
>
> This patch allows SCCVN to look through the VCE.
>
> OK? Bootstrapped and tested on i686-linux-gnu with no regressions.
The visit_reference_op_store parts look unnecessary, at least for
the testcases. It also isn't obvious to me that we handle type
mismatches there (it is of course for the load case).
So, ok if you omit the visit_reference_op_store parts.
Thanks,
Richard.
> Thanks,
> Andrew Pinski
>
> ChangeLog:
> * tree-ssa-sccvn.c (visit_reference_op_load): If vn_reference_lookup
> is returns NULL and OP is a VCE, look through the VCE.
> (visit_reference_op_store): Unwrap the VCE.
>
> * gcc.dg/tree-ssa/fre-vce-1.c: New testcase.
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-04-23 9:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-22 21:11 [PATCH] Fix PR tree-opt/38865 missing FRE with VIEW_CONVERT_EXPR Andrew Pinski
2009-04-23 9:02 ` Richard Guenther
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).