https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113985

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |NEW
           Keywords|                            |internal-improvement
     Ever confirmed|0                           |1
          Component|rtl-optimization            |middle-end
           Severity|normal                      |enhancement
            Summary|redundant copy of return    |expansion of `*struct =
                   |values at O0                |call();` could be improved
         Resolution|INVALID                     |---
   Last reconfirmed|                            |2024-02-19

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Just for reference this comes from the expansion of *b = call.

What is happening is it is loading the original variable from *b and then
ioring the new value in. This should be improved but not because of the -O0
case but rather it would be better for expansion reasons and better initial
RTL.

Not we normally don't care about -O0 code size/generation but in this case, it
just that it would help improve compile time slightly.

I have not looked fully into what produces the tmp = (a&0) just yet though.
But the initial RTL (even at -O2) is:
```
(insn 28 27 29 (set (reg:SI 112)
        (mem/c:SI (reg/f:DI 110) [1 g_91D.2780+8 S4 A64]))
"/app/example.cpp":27:8 -1
     (nil))

(insn 29 28 30 (parallel [
            (set (reg:SI 113)
                (and:SI (reg:SI 112)
                    (const_int 0 [0])))
            (clobber (reg:CC 17 flags))
        ]) "/app/example.cpp":27:8 -1
     (nil))

(insn 30 29 31 (parallel [
            (set (reg:SI 114)
                (ior:SI (reg:SI 113)
                    (reg:SI 111)))
            (clobber (reg:CC 17 flags))
        ]) "/app/example.cpp":27:8 -1
     (nil))

```

Which seems like it definitely could be improved.

Reply via email to