[Bug middle-end/115534] intermediate stack use not eliminated

2024-06-18 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115534

Andrew Pinski  changed:

   What|Removed |Added

  Component|tree-optimization   |middle-end
   Severity|normal  |enhancement

[Bug middle-end/115534] intermediate stack use not eliminated

2024-06-18 Thread tnfchris at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115534

--- Comment #2 from Tamar Christina  ---
(In reply to Andrew Pinski from comment #1)
> I suspect there is a dup of this already. See the bug which I made this one
> blocking for a list of related bugs.

Most of the other bugs relate to the argument expansions, however this one,
regardless of the expansion itself shouldn't need the intermediate stack.

I think there are various other ways the operation could have been kept in a
gimple register.

[Bug middle-end/115534] intermediate stack use not eliminated

2024-06-18 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115534

Andrew Pinski  changed:

   What|Removed |Added

   Last reconfirmed||2024-06-18
 Status|UNCONFIRMED |NEW
 Ever confirmed|0   |1

--- Comment #3 from Andrew Pinski  ---
Confirmed.

Note even without vectorizer turned on we get really bad code from the return
when expanding (just happens the RTL optimizers can remove the load/stores but
not the stack location):
```

;; return D.4535;

(insn 60 59 61 (set (reg:DF 156)
(mem/c:DF (plus:DI (reg/f:DI 95 virtual-stack-vars)
(const_int -32 [0xffe0])) [4 D.4535+0 S8 A128]))
"/app/example.cpp":24:12 -1
 (nil))

(insn 61 60 62 (set (reg:DF 157)
(mem/c:DF (plus:DI (reg/f:DI 95 virtual-stack-vars)
(const_int -24 [0xffe8])) [4 D.4535+8 S8 A64]))
"/app/example.cpp":24:12 -1
 (nil))

(insn 62 61 63 (set (reg:DF 158)
(mem/c:DF (plus:DI (reg/f:DI 95 virtual-stack-vars)
(const_int -16 [0xfff0])) [4 D.4535+16 S8 A128]))
"/app/example.cpp":24:12 -1
 (nil))

(insn 63 62 64 (set (reg:DF 159)
(mem/c:DF (plus:DI (reg/f:DI 95 virtual-stack-vars)
(const_int -8 [0xfff8])) [4 D.4535+24 S8 A64]))
"/app/example.cpp":24:12 -1
 (nil))

(insn 64 63 65 (set (reg:DF 132 [  ])
(reg:DF 156)) "/app/example.cpp":24:12 -1
 (nil))

(insn 65 64 66 (set (reg:DF 133 [ +8 ])
(reg:DF 157)) "/app/example.cpp":24:12 -1
 (nil))

(insn 66 65 67 (set (reg:DF 134 [ +16 ])
(reg:DF 158)) "/app/example.cpp":24:12 -1
 (nil))

(insn 67 66 68 (set (reg:DF 135 [ +24 ])
(reg:DF 159)) "/app/example.cpp":24:12 -1
 (nil))

(jump_insn 68 67 69 (set (pc)
(label_ref 0)) "/app/example.cpp":24:12 -1
 (nil))
```

On the stack location we get:
```
sub sp, sp, #64
```

This is why I said there are a few duplicates there ...

[Bug middle-end/115534] intermediate stack use not eliminated

2024-06-18 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115534

--- Comment #4 from Andrew Pinski  ---
This might be improved by
https://gcc.gnu.org/pipermail/gcc-patches/2024-June/654819.html . Or it might
be the case the vectorizer case needs to be improved afterwards. But I think
that is the infrastructure for fixing this issue.

[Bug middle-end/115534] intermediate stack use not eliminated

2024-06-18 Thread tnfchris at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115534

--- Comment #5 from Tamar Christina  ---
(In reply to Andrew Pinski from comment #4)
> This might be improved by
> https://gcc.gnu.org/pipermail/gcc-patches/2024-June/654819.html . Or it
> might be the case the vectorizer case needs to be improved afterwards. But I
> think that is the infrastructure for fixing this issue.

Yeah Richard pointed me to this today as well. The vectorizer case is a bit
unique because the vectorizer has packed scalar values in two vector registers.

So yeah think it's likely some work will be needed afterwards but will see
after the fsra patch lands :)