[Bug tree-optimization/114704] Missed optimization : eliminate store if the value is known in all predecessors

2024-04-15 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114704

--- Comment #5 from Richard Biener  ---
We're not handling "phi translation" in the lookup phase when determining if
there's a redundant store (PHI translation for the virtual operand).  In
particular value-numbering never considers whether an expression
in multiple paths into a CFG merge value-numbers the same.  This is only
done as part of PRE which figures some extra fully redundant expressions.
But the redundant store removal is something done after-the-fact using
just the VN machinery.

[Bug tree-optimization/114704] Missed optimization : eliminate store if the value is known in all predecessors

2024-04-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114704

--- Comment #4 from Andrew Pinski  ---
(In reply to XChy from comment #3)
> Do you mean "*p = a" at the end?

In this case a and t should be the same value :). So it does not matter. I was
showing that sometimes gcc messes up when using the original value.

[Bug tree-optimization/114704] Missed optimization : eliminate store if the value is known in all predecessors

2024-04-13 Thread xxs_chy at outlook dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114704

--- Comment #3 from XChy  ---
(In reply to Andrew Pinski from comment #1)
> Confirmed. A more general testcase:
> ```
> void dummy();
> 
> void src(int *p, int a){
> int t = *p;
> if(t == a)
> goto then;
> else {
> dummy();
> t = *p;
> if(t == a)
> goto then;
> else
> return;
> }
> 
> then:
> *p = t; // *p is already a, it's dead now
> }
> 
> ```

Do you mean "*p = a" at the end?

[Bug tree-optimization/114704] Missed optimization : eliminate store if the value is known in all predecessors

2024-04-12 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114704

Andrew Pinski  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=20999

--- Comment #2 from Andrew Pinski  ---
Related to PR 20999.

[Bug tree-optimization/114704] Missed optimization : eliminate store if the value is known in all predecessors

2024-04-12 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114704

Andrew Pinski  changed:

   What|Removed |Added

 Ever confirmed|0   |1
   Last reconfirmed||2024-04-12
 Status|UNCONFIRMED |NEW

--- Comment #1 from Andrew Pinski  ---
Confirmed. A more general testcase:
```
void dummy();

void src(int *p, int a){
int t = *p;
if(t == a)
goto then;
else {
dummy();
t = *p;
if(t == a)
goto then;
else
return;
}

then:
*p = t; // *p is already a, it's dead now
}

```

[Bug tree-optimization/114704] Missed optimization : eliminate store if the value is known in all predecessors

2024-04-12 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114704

Andrew Pinski  changed:

   What|Removed |Added

   Severity|normal  |enhancement
   Keywords||missed-optimization