[Bug tree-optimization/115034] Missed optimization: reduntant store of identical value in the slot

2024-05-13 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115034

Richard Biener  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Keywords||missed-optimization
   Last reconfirmed||2024-05-13
 Ever confirmed|0   |1

--- Comment #3 from Richard Biener  ---
This would work if we'd duplicate the path from a = 0 to *outl = 1; return 0;
but we don't early enough (on GIMPLE) and we don't do that on RTL until
BB reorder where ther's no later pass doing this optimization either.

On GIMPLE we see

   [local count: 1073741824]:
  *outl_4(D) = 0;
  if (c1_6(D) != 0)
goto ; [50.00%]
  else
goto ; [50.00%]
...
   [local count: 965079152]:
  # a_1 = PHI <1(3), 0(2)>
  *outl_4(D) = a_1;
  return 0;

but I think tracer doesn't consider paths to exit aka tail duplication,
likely because on GIMPLE we force a single return block.  There's also
no partial redundant store elimination.

[Bug tree-optimization/115034] Missed optimization: reduntant store of identical value in the slot

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

--- Comment #2 from XChy  ---
(In reply to Andrew Pinski from comment #1)
> Note there is some memory model requirements here that I always forget if
> this can happen or not.

Hmm. Could you please provide some documents about the memory model of GCC or
specific constraints about C language? The semantics of IR in the LLVM issue
look good to me, since the store is non-volatile and non-atomic. But I'm not
sure how it would be after lifting to C.

[Bug tree-optimization/115034] Missed optimization: reduntant store of identical value in the slot

2024-05-10 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115034

--- Comment #1 from Andrew Pinski  ---
Note there is some memory model requirements here that I always forget if this
can happen or not.