* [PATCH] cplxlower: Avoid a transform when looking at a default definition
@ 2020-10-16 18:46 Martin Jambor
2020-10-17 9:46 ` Richard Biener
0 siblings, 1 reply; 3+ messages in thread
From: Martin Jambor @ 2020-10-16 18:46 UTC (permalink / raw)
To: GCC Patches; +Cc: Richard Biener
Hi,
in PR 97456, IPA-SRA triggers a bug in tree-complex.c where it
converts:
<bb 2>
a$_M_value_21 = COMPLEX_EXPR <ISRA.18_10(D), ISRA.18_10(D)>;
(where ISRA.18 is IPA-SRA created PARM_DECL with DECL_IGNORED_P set,
which is why it only happens with IPA-SRA) into:
<bb 2>
a$_M_value_21 = COMPLEX_EXPR <a$_M_value$real_10(D), a$_M_value$real_10(D)>;
i.e. it replaces two uses of the parameter default-def with two
uninitialized default-defs of a new variable - all in hope to produce
code with better debug info.
This patch fixes it by avoiding the transform when the SSA_NAME to be
replaced is a default definition. Bootstrapped and tested on
x86_64-linux. OK for trunk and the gcc-10 branch?
Thanks,
Martin
gcc/ChangeLog:
2020-10-16 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/97456
* tree-complex.c (set_component_ssa_name): Do not replace ignored decl
default definitions with new component vars. Reorder if conditions.
gcc/testsuite/ChangeLog:
2020-10-16 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/97456
* gcc.dg/tree-ssa/pr97456.c: New test.
---
gcc/testsuite/gcc.dg/tree-ssa/pr97456.c | 40 +++++++++++++++++++++++++
gcc/tree-complex.c | 6 ++--
2 files changed, 44 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr97456.c
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr97456.c b/gcc/testsuite/gcc.dg/tree-ssa/pr97456.c
new file mode 100644
index 00000000000..5171c9b4577
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr97456.c
@@ -0,0 +1,40 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fwhole-program" } */
+
+
+float val2 = 1.710780f;
+float val3;
+volatile float vf;
+
+int __attribute__((noipa))
+get_bool (void)
+{
+ return 1;
+}
+
+int __attribute__((noinline))
+wrong (float *pos)
+{
+ _Complex float a;
+
+ __real__ a = *pos;
+ __imag__ a = *pos;
+
+ _Complex float b = 0 + 0i;
+
+ b = b + a;
+
+ if (b == 0.0f)
+ return 1;
+
+ vf = __imag__ b;
+ return 0;
+}
+
+int main(int argc, char **argv) {
+ float val = get_bool () == 1 ? val2 : val3;
+
+ if ((wrong(&val), wrong(&val)))
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c
index 2e54bbb917c..71ad7c18523 100644
--- a/gcc/tree-complex.c
+++ b/gcc/tree-complex.c
@@ -570,8 +570,10 @@ set_component_ssa_name (tree ssa_name, bool imag_p, tree value)
/* Replace an anonymous base value with the variable from cvc_lookup.
This should result in better debug info. */
if (SSA_NAME_VAR (ssa_name)
- && (!SSA_NAME_VAR (value) || DECL_IGNORED_P (SSA_NAME_VAR (value)))
- && !DECL_IGNORED_P (SSA_NAME_VAR (ssa_name)))
+ && !DECL_IGNORED_P (SSA_NAME_VAR (ssa_name))
+ && (!SSA_NAME_VAR (value)
+ || (DECL_IGNORED_P (SSA_NAME_VAR (value))
+ && !SSA_NAME_IS_DEFAULT_DEF (value))))
{
comp = get_component_var (SSA_NAME_VAR (ssa_name), imag_p);
replace_ssa_name_symbol (value, comp);
--
2.28.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] cplxlower: Avoid a transform when looking at a default definition
2020-10-16 18:46 [PATCH] cplxlower: Avoid a transform when looking at a default definition Martin Jambor
@ 2020-10-17 9:46 ` Richard Biener
2020-10-19 14:43 ` Martin Jambor
0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2020-10-17 9:46 UTC (permalink / raw)
To: Martin Jambor, GCC Patches
On October 16, 2020 8:46:39 PM GMT+02:00, Martin Jambor <mjambor@suse.cz> wrote:
>Hi,
>
>in PR 97456, IPA-SRA triggers a bug in tree-complex.c where it
>converts:
>
> <bb 2>
> a$_M_value_21 = COMPLEX_EXPR <ISRA.18_10(D), ISRA.18_10(D)>;
>
>(where ISRA.18 is IPA-SRA created PARM_DECL with DECL_IGNORED_P set,
>which is why it only happens with IPA-SRA) into:
>
> <bb 2>
>a$_M_value_21 = COMPLEX_EXPR <a$_M_value$real_10(D),
>a$_M_value$real_10(D)>;
>
>i.e. it replaces two uses of the parameter default-def with two
>uninitialized default-defs of a new variable - all in hope to produce
>code with better debug info.
>
>This patch fixes it by avoiding the transform when the SSA_NAME to be
>replaced is a default definition. Bootstrapped and tested on
>x86_64-linux. OK for trunk and the gcc-10 branch?
It's never OK to replace SSA_NAME_VAR of a default Def so may I suggest to put this restriction first, independent of any other predicate?
Ok with that change. Thanks,
Richard.
>Thanks,
>
>Martin
>
>
>gcc/ChangeLog:
>
>2020-10-16 Martin Jambor <mjambor@suse.cz>
>
> PR tree-optimization/97456
> * tree-complex.c (set_component_ssa_name): Do not replace ignored decl
> default definitions with new component vars. Reorder if conditions.
>
>gcc/testsuite/ChangeLog:
>
>2020-10-16 Martin Jambor <mjambor@suse.cz>
>
> PR tree-optimization/97456
> * gcc.dg/tree-ssa/pr97456.c: New test.
>---
> gcc/testsuite/gcc.dg/tree-ssa/pr97456.c | 40 +++++++++++++++++++++++++
> gcc/tree-complex.c | 6 ++--
> 2 files changed, 44 insertions(+), 2 deletions(-)
> create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr97456.c
>
>diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr97456.c
>b/gcc/testsuite/gcc.dg/tree-ssa/pr97456.c
>new file mode 100644
>index 00000000000..5171c9b4577
>--- /dev/null
>+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr97456.c
>@@ -0,0 +1,40 @@
>+/* { dg-do run } */
>+/* { dg-options "-O2 -fwhole-program" } */
>+
>+
>+float val2 = 1.710780f;
>+float val3;
>+volatile float vf;
>+
>+int __attribute__((noipa))
>+get_bool (void)
>+{
>+ return 1;
>+}
>+
>+int __attribute__((noinline))
>+wrong (float *pos)
>+{
>+ _Complex float a;
>+
>+ __real__ a = *pos;
>+ __imag__ a = *pos;
>+
>+ _Complex float b = 0 + 0i;
>+
>+ b = b + a;
>+
>+ if (b == 0.0f)
>+ return 1;
>+
>+ vf = __imag__ b;
>+ return 0;
>+}
>+
>+int main(int argc, char **argv) {
>+ float val = get_bool () == 1 ? val2 : val3;
>+
>+ if ((wrong(&val), wrong(&val)))
>+ __builtin_abort ();
>+ return 0;
>+}
>diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c
>index 2e54bbb917c..71ad7c18523 100644
>--- a/gcc/tree-complex.c
>+++ b/gcc/tree-complex.c
>@@ -570,8 +570,10 @@ set_component_ssa_name (tree ssa_name, bool
>imag_p, tree value)
> /* Replace an anonymous base value with the variable from cvc_lookup.
> This should result in better debug info. */
> if (SSA_NAME_VAR (ssa_name)
>- && (!SSA_NAME_VAR (value) || DECL_IGNORED_P (SSA_NAME_VAR (value)))
>- && !DECL_IGNORED_P (SSA_NAME_VAR (ssa_name)))
>+ && !DECL_IGNORED_P (SSA_NAME_VAR (ssa_name))
>+ && (!SSA_NAME_VAR (value)
>+ || (DECL_IGNORED_P (SSA_NAME_VAR (value))
>+ && !SSA_NAME_IS_DEFAULT_DEF (value))))
> {
> comp = get_component_var (SSA_NAME_VAR (ssa_name), imag_p);
> replace_ssa_name_symbol (value, comp);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] cplxlower: Avoid a transform when looking at a default definition
2020-10-17 9:46 ` Richard Biener
@ 2020-10-19 14:43 ` Martin Jambor
0 siblings, 0 replies; 3+ messages in thread
From: Martin Jambor @ 2020-10-19 14:43 UTC (permalink / raw)
To: Richard Biener, GCC Patches
Hi,
On Sat, Oct 17 2020, Richard Biener wrote:
> On October 16, 2020 8:46:39 PM GMT+02:00, Martin Jambor <mjambor@suse.cz> wrote:
>>Hi,
>>
>>in PR 97456, IPA-SRA triggers a bug in tree-complex.c where it
>>converts:
>>
>> <bb 2>
>> a$_M_value_21 = COMPLEX_EXPR <ISRA.18_10(D), ISRA.18_10(D)>;
>>
>>(where ISRA.18 is IPA-SRA created PARM_DECL with DECL_IGNORED_P set,
>>which is why it only happens with IPA-SRA) into:
>>
>> <bb 2>
>>a$_M_value_21 = COMPLEX_EXPR <a$_M_value$real_10(D),
>>a$_M_value$real_10(D)>;
>>
>>i.e. it replaces two uses of the parameter default-def with two
>>uninitialized default-defs of a new variable - all in hope to produce
>>code with better debug info.
>>
>>This patch fixes it by avoiding the transform when the SSA_NAME to be
>>replaced is a default definition. Bootstrapped and tested on
>>x86_64-linux. OK for trunk and the gcc-10 branch?
>
> It's never OK to replace SSA_NAME_VAR of a default Def so may I suggest to put this restriction first, independent of any other predicate?
>
OK, I've rebased the following on the current master and will commit it
after the final round of testing.
Thanks,
Martin
gcc/ChangeLog:
2020-10-19 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/97456
* tree-complex.c (set_component_ssa_name): Do not replace ignored decl
default definitions with new component vars.
gcc/testsuite/ChangeLog:
2020-10-19 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/97456
* gcc.dg/tree-ssa/pr97456.c: New test.
---
gcc/testsuite/gcc.dg/tree-ssa/pr97456.c | 40 +++++++++++++++++++++++++
gcc/tree-complex.c | 3 +-
2 files changed, 42 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr97456.c
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr97456.c b/gcc/testsuite/gcc.dg/tree-ssa/pr97456.c
new file mode 100644
index 00000000000..5171c9b4577
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr97456.c
@@ -0,0 +1,40 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fwhole-program" } */
+
+
+float val2 = 1.710780f;
+float val3;
+volatile float vf;
+
+int __attribute__((noipa))
+get_bool (void)
+{
+ return 1;
+}
+
+int __attribute__((noinline))
+wrong (float *pos)
+{
+ _Complex float a;
+
+ __real__ a = *pos;
+ __imag__ a = *pos;
+
+ _Complex float b = 0 + 0i;
+
+ b = b + a;
+
+ if (b == 0.0f)
+ return 1;
+
+ vf = __imag__ b;
+ return 0;
+}
+
+int main(int argc, char **argv) {
+ float val = get_bool () == 1 ? val2 : val3;
+
+ if ((wrong(&val), wrong(&val)))
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c
index 2e54bbb917c..f132e0f41c7 100644
--- a/gcc/tree-complex.c
+++ b/gcc/tree-complex.c
@@ -569,7 +569,8 @@ set_component_ssa_name (tree ssa_name, bool imag_p, tree value)
{
/* Replace an anonymous base value with the variable from cvc_lookup.
This should result in better debug info. */
- if (SSA_NAME_VAR (ssa_name)
+ if (!SSA_NAME_IS_DEFAULT_DEF (value)
+ && SSA_NAME_VAR (ssa_name)
&& (!SSA_NAME_VAR (value) || DECL_IGNORED_P (SSA_NAME_VAR (value)))
&& !DECL_IGNORED_P (SSA_NAME_VAR (ssa_name)))
{
--
2.28.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-10-19 14:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-16 18:46 [PATCH] cplxlower: Avoid a transform when looking at a default definition Martin Jambor
2020-10-17 9:46 ` Richard Biener
2020-10-19 14:43 ` Martin Jambor
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).