[Bug middle-end/53875] calls to const functions are eliminated at -O0

2021-11-29 Thread roger at nextmovesoftware dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53875

--- Comment #6 from Roger Sayle  ---
I believe this should be "... && optimize != 0", i.e. we want to eliminate
these calls (only) when optimizing.  But this seems like a reasonable
fix/feature request (to identify breakpoints at -O0).

[Bug middle-end/53875] calls to const functions are eliminated at -O0

2021-11-28 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53875

Andrew Pinski  changed:

   What|Removed |Added

 CC||roger at nextmovesoftware dot 
com

--- Comment #5 from Andrew Pinski  ---
diff --git a/gcc/calls.c b/gcc/calls.c
index 27b59f26ad3..f23dde58671 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -2735,7 +2735,8 @@ expand_call (tree exp, rtx target, int ignore)
   && (!(flags & ECF_LOOPING_CONST_OR_PURE))
   && (flags & ECF_NOTHROW)
   && (ignore || target == const0_rtx
- || TYPE_MODE (rettype) == VOIDmode))
+ || TYPE_MODE (rettype) == VOIDmode)
+  && !optimize)
 {
   bool volatilep = false;
   tree arg;

[Bug middle-end/53875] calls to const functions are eliminated at -O0

2021-11-28 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53875

--- Comment #4 from Andrew Pinski  ---
(In reply to Andrew Pinski from comment #3)
> The code which introduced this was
> g:8c6a82695b85f8ed74cdc67f2cf74c5a62d0d91d .

https://gcc.gnu.org/pipermail/gcc-patches/2003-May/104797.html

[Bug middle-end/53875] calls to const functions are eliminated at -O0

2021-11-28 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53875

Andrew Pinski  changed:

   What|Removed |Added

  Known to work||3.3.3
  Known to fail||3.4.0

--- Comment #3 from Andrew Pinski  ---
The code which introduced this was g:8c6a82695b85f8ed74cdc67f2cf74c5a62d0d91d .

[Bug middle-end/53875] calls to const functions are eliminated at -O0

2021-07-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53875

Andrew Pinski  changed:

   What|Removed |Added

  Component|c++ |middle-end

--- Comment #2 from Andrew Pinski  ---
This even happens in C.
It happens during expand phase:
;; Generating RTL for gimple basic block 2

;; pthread_self ();

(nil)

Maybe at -O0 or -Og, during expand we still expand the call ...