[Bug ipa/89139] GCC emits code for static functions that aren't used by the optimized code

2019-02-08 Thread m...@nieper-wisskirchen.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89139 --- Comment #6 from Marc Nieper-Wißkirchen --- Interestingly, the above code, slightly modified, exhibits another problem the optimizer has: void foo (); static void c (void (*w) (void)) { w (); } static void f () { foo (); } static v

[Bug ipa/89139] GCC emits code for static functions that aren't used by the optimized code

2019-02-08 Thread m...@nieper-wisskirchen.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89139 --- Comment #5 from Marc Nieper-Wißkirchen --- Here is a much simpler example, which exhibits the same behavior: static void c (void (*w) (void)) { w (); } static void f () { } static void *x = &f; void g () { c (x); } The compiler o

[Bug tree-optimization/89184] New: GCC does not simplify expressions involving shifts, bitwise operators and comparisons.

2019-02-04 Thread m...@nieper-wisskirchen.de
Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: m...@nieper-wisskirchen.de Target Milestone: --- GCC compiles the function int foo (unsigned i) { return ((i >> 1) & 3) == 2; } to

[Bug tree-optimization/89152] Wrapping values in structures can make the optimizer blind

2019-02-04 Thread m...@nieper-wisskirchen.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89152 --- Comment #2 from Marc Nieper-Wißkirchen --- Even if Cont weren't passed in a register, the optimization of the unwrapped, first version would be missed in the structure-wrapped, second version. A general solution where such simple wrappers do

[Bug tree-optimization/43565] Missed address comparison folding of DECL_COMMONs

2019-02-02 Thread m...@nieper-wisskirchen.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43565 --- Comment #11 from Marc Nieper-Wißkirchen --- If ISO C allows such linkage to be created outside of the standard, a number of other assumption would be violated as well: In 6.2.4 (2) it says that "an object exists, has a constant address, and

[Bug ipa/89139] GCC emits code for static functions that aren't used by the optimized code

2019-02-02 Thread m...@nieper-wisskirchen.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89139 --- Comment #4 from Marc Nieper-Wißkirchen --- P.S.: This issue showed up when I tried to analyze why no optimization is happening in bug #89152.

[Bug tree-optimization/43565] Missed address comparison folding of DECL_COMMONs

2019-02-01 Thread m...@nieper-wisskirchen.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43565 --- Comment #9 from Marc Nieper-Wißkirchen --- Footnote 29) in section 6.2.2 of the latest draft (N2176) for C18 says: "There is no linkage between different identifiers."

[Bug tree-optimization/89152] New: Wrapping values in structures can make the optimizer blind

2019-02-01 Thread m...@nieper-wisskirchen.de
Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: m...@nieper-wisskirchen.de Target Milestone: --- GCC compiles the following C module ** typedef void (*Cont) (void *f, int a); int quux (int a); static void g (Cont c, Cont d

[Bug tree-optimization/43565] Missed address comparison folding of DECL_COMMONs

2019-02-01 Thread m...@nieper-wisskirchen.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43565 --- Comment #7 from Marc Nieper-Wißkirchen --- I'm sorry, I wasn't precise what I meant. When I wrote that the optimization wouldn't be possible I meant the case of two externally defined variables, e.g. extern int p; extern int q; One can forc

[Bug tree-optimization/43565] Missed address comparison folding of DECL_COMMONs

2019-02-01 Thread m...@nieper-wisskirchen.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43565 --- Comment #5 from Marc Nieper-Wißkirchen --- If that was possible (that symbols are aliased in the TU in which they are defined, but not (explicitly) in a TU where they are declared), there would be the need of a "no_alias" (or "never_alias") a

[Bug tree-optimization/89145] New: GCC does not assume that two different external variables have different addresses

2019-01-31 Thread m...@nieper-wisskirchen.de
Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: m...@nieper-wisskirchen.de Target Milestone: --- The module: ** extern int p; extern int q; int foo (void) { return &p == &q; } ** is com

[Bug tree-optimization/89139] New: GCC emits code for static functions that aren't used by the optimized code

2019-01-31 Thread m...@nieper-wisskirchen.de
erity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: m...@nieper-wisskirchen.de Target Milestone: --- Consider the following C module. ** typedef struct cont { void (*f) (struct cont, int a); } Cont;