public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/112266] New: `constcall(a)` and `constcall(&a->b[0])` is not being optimized to one call
@ 2023-10-28 18:34 pinskia at gcc dot gnu.org
  2023-10-30 13:27 ` [Bug tree-optimization/112266] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-28 18:34 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112266
           Summary: `constcall(a)` and `constcall(&a->b[0])` is not being
                    optimized to one call
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
struct a
{
        int b[1];
};

[[gnu::const]]
int constcall(int *a);

int f(struct a *b)
{
  int *c = b->b;
  int *d = (int*)b;
  int t = constcall(c);
  int t1 = constcall(d);
  return t+t1;
}

```

There should only be one call to constcall since the argument is the exact same
value just represented slightly different in the IR.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/112266] `constcall(a)` and `constcall(&a->b[0])` is not being optimized to one call
  2023-10-28 18:34 [Bug tree-optimization/112266] New: `constcall(a)` and `constcall(&a->b[0])` is not being optimized to one call pinskia at gcc dot gnu.org
@ 2023-10-30 13:27 ` rguenth at gcc dot gnu.org
  2023-10-30 14:06 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-10-30 13:27 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-10-30

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
  __BB(2):
  c_2 = &b_1(D)->b;
  t_4 = constcall (c_2);
  t1_5 = constcall (b_1(D));
  _6 = t_4 + t1_5;
  return _6;

diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
index 0b2c10dcc1a..c52a846abed 100644
--- a/gcc/tree-ssa-sccvn.cc
+++ b/gcc/tree-ssa-sccvn.cc
@@ -3975,6 +3975,8 @@ vn_reference_lookup (tree op, tree vuse, vn_lookup_kind
kind,
              == sext_hwi (off.coeffs[0], TYPE_PRECISION (sizetype))))
        {
          gcc_assert (operands[i-1].opcode == MEM_REF);
+         if (known_eq (off, 0))
+           return operands[i].op0;
          tree ops[2];
          ops[0] = operands[i].op0;
          ops[1] = wide_int_to_tree (sizetype, off);

Mine.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/112266] `constcall(a)` and `constcall(&a->b[0])` is not being optimized to one call
  2023-10-28 18:34 [Bug tree-optimization/112266] New: `constcall(a)` and `constcall(&a->b[0])` is not being optimized to one call pinskia at gcc dot gnu.org
  2023-10-30 13:27 ` [Bug tree-optimization/112266] " rguenth at gcc dot gnu.org
@ 2023-10-30 14:06 ` rguenth at gcc dot gnu.org
  2023-10-30 14:08 ` rguenth at gcc dot gnu.org
  2023-10-30 19:15 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-10-30 14:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Wheeeeee - late diagnostic fallout galore!  Putting on hold.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/112266] `constcall(a)` and `constcall(&a->b[0])` is not being optimized to one call
  2023-10-28 18:34 [Bug tree-optimization/112266] New: `constcall(a)` and `constcall(&a->b[0])` is not being optimized to one call pinskia at gcc dot gnu.org
  2023-10-30 13:27 ` [Bug tree-optimization/112266] " rguenth at gcc dot gnu.org
  2023-10-30 14:06 ` rguenth at gcc dot gnu.org
@ 2023-10-30 14:08 ` rguenth at gcc dot gnu.org
  2023-10-30 19:15 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-10-30 14:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Created attachment 56475
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56475&action=edit
patch

 Running target unix
+FAIL: c-c++-common/Warray-bounds.c  -std=gnu++98  (test for warnings, line
183)
+FAIL: c-c++-common/Warray-bounds.c  -std=gnu++14  (test for warnings, line
183)
+FAIL: c-c++-common/Warray-bounds.c  -std=gnu++17  (test for warnings, line
183)
+FAIL: c-c++-common/Warray-bounds.c  -std=gnu++20  (test for warnings, line
183)
+FAIL: c-c++-common/Wstringop-truncation-4.c  -std=gnu++98  (test for warnings,
line 28)
+FAIL: c-c++-common/Wstringop-truncation-4.c  -std=gnu++98  (test for warnings,
line 58)
+FAIL: c-c++-common/Wstringop-truncation-4.c  -std=gnu++98  (test for warnings,
line 88)
+FAIL: c-c++-common/Wstringop-truncation-4.c  -std=gnu++98  (test for warnings,
line 118)
+FAIL: c-c++-common/Wstringop-truncation-4.c  -std=gnu++14  (test for warnings,
line 28)
+FAIL: c-c++-common/Wstringop-truncation-4.c  -std=gnu++14  (test for warnings,
line 58)
+FAIL: c-c++-common/Wstringop-truncation-4.c  -std=gnu++14  (test for warnings,
line 88)
+FAIL: c-c++-common/Wstringop-truncation-4.c  -std=gnu++14  (test for warnings,
line 118)
+FAIL: c-c++-common/Wstringop-truncation-4.c  -std=gnu++17  (test for warnings,
line 28)
+FAIL: c-c++-common/Wstringop-truncation-4.c  -std=gnu++17  (test for warnings,
line 58)
+FAIL: c-c++-common/Wstringop-truncation-4.c  -std=gnu++17  (test for warnings,
line 88)
+FAIL: c-c++-common/Wstringop-truncation-4.c  -std=gnu++17  (test for warnings,
line 118)
+FAIL: c-c++-common/Wstringop-truncation-4.c  -std=gnu++20  (test for warnings,
line 28)
+FAIL: c-c++-common/Wstringop-truncation-4.c  -std=gnu++20  (test for warnings,
line 58)
+FAIL: c-c++-common/Wstringop-truncation-4.c  -std=gnu++20  (test for warnings,
line 88)
+FAIL: c-c++-common/Wstringop-truncation-4.c  -std=gnu++20  (test for warnings,
line 118)
+FAIL: c-c++-common/Wstringop-truncation.c  -std=gnu++98  (test for warnings,
line 299)
+FAIL: c-c++-common/Wstringop-truncation.c  -std=gnu++98  (test for warnings,
line 300)
+FAIL: c-c++-common/Wstringop-truncation.c  -std=gnu++98 member array (test for
warnings, line 302)
+FAIL: c-c++-common/Wstringop-truncation.c  -std=gnu++98  (test for warnings,
line 373)
+FAIL: c-c++-common/Wstringop-truncation.c  -std=gnu++98  (test for warnings,
line 429)
+FAIL: c-c++-common/Wstringop-truncation.c  -std=gnu++98  (test for warnings,
line 430)
+FAIL: c-c++-common/Wstringop-truncation.c  -std=gnu++14  (test for warnings,
line 299)
+FAIL: c-c++-common/Wstringop-truncation.c  -std=gnu++14  (test for warnings,
line 300)
+FAIL: c-c++-common/Wstringop-truncation.c  -std=gnu++14 member array (test for
warnings, line 302)
+FAIL: c-c++-common/Wstringop-truncation.c  -std=gnu++14  (test for warnings,
line 373)
+FAIL: c-c++-common/Wstringop-truncation.c  -std=gnu++14  (test for warnings,
line 429)
+FAIL: c-c++-common/Wstringop-truncation.c  -std=gnu++14  (test for warnings,
line 430)
+FAIL: c-c++-common/Wstringop-truncation.c  -std=gnu++17  (test for warnings,
line 299)
+FAIL: c-c++-common/Wstringop-truncation.c  -std=gnu++17  (test for warnings,
line 300)
+FAIL: c-c++-common/Wstringop-truncation.c  -std=gnu++17 member array (test for
warnings, line 302)
+FAIL: c-c++-common/Wstringop-truncation.c  -std=gnu++17  (test for warnings,
line 373)
+FAIL: c-c++-common/Wstringop-truncation.c  -std=gnu++17  (test for warnings,
line 429)
+FAIL: c-c++-common/Wstringop-truncation.c  -std=gnu++17  (test for warnings,
line 430)
+FAIL: c-c++-common/Wstringop-truncation.c  -std=gnu++20  (test for warnings,
line 299)
+FAIL: c-c++-common/Wstringop-truncation.c  -std=gnu++20  (test for warnings,
line 300)
+FAIL: c-c++-common/Wstringop-truncation.c  -std=gnu++20 member array (test for
warnings, line 302)
+FAIL: c-c++-common/Wstringop-truncation.c  -std=gnu++20  (test for warnings,
line 373)
+FAIL: c-c++-common/Wstringop-truncation.c  -std=gnu++20  (test for warnings,
line 429)
+FAIL: c-c++-common/Wstringop-truncation.c  -std=gnu++20  (test for warnings,
line 430)
+FAIL: g++.dg/warn/Wstringop-overflow-1.C  -std=c++98  (test for warnings, line
14)
+FAIL: g++.dg/warn/Wstringop-overflow-1.C  -std=c++14  (test for warnings, line
14)
+FAIL: g++.dg/warn/Wstringop-overflow-1.C  -std=c++17  (test for warnings, line
14)
+FAIL: g++.dg/warn/Wstringop-overflow-1.C  -std=c++20  (test for warnings, line
14)
 FAIL: g++.dg/guality/pr55665.C   -O2 -flto -fno-use-linker-plugin
-flto-partition=none  line 23 p == 40
+FAIL: g++.dg/tree-prof/devirt.C scan-tree-dump-times tracer "folding virtual
function call to virtual unsigned int mozPersonalDictionary::_ZThn16" 1
 FAIL: g++.dg/tsan/pthread_cond_clockwait.C   -O0  execution test
 FAIL: g++.dg/tsan/pthread_cond_clockwait.C   -O2  execution test

                === g++ Summary ===

-# of expected passes           248265
-# of unexpected failures       3
+# of expected passes           248216
+# of unexpected failures       52
 # of expected failures         2578
 # of unsupported tests         10741


+FAIL: c-c++-common/Warray-bounds.c  -Wc++-compat   (test for warnings, line
183)
+FAIL: c-c++-common/Wstringop-truncation-4.c  -Wc++-compat   (test for
warnings, line 28)
+FAIL: c-c++-common/Wstringop-truncation-4.c  -Wc++-compat   (test for
warnings, line 58)
+FAIL: c-c++-common/Wstringop-truncation-4.c  -Wc++-compat   (test for
warnings, line 88)
+FAIL: c-c++-common/Wstringop-truncation-4.c  -Wc++-compat   (test for
warnings, line 118)
+FAIL: c-c++-common/Wstringop-truncation.c  -Wc++-compat   (test for warnings,
line 299)
+FAIL: c-c++-common/Wstringop-truncation.c  -Wc++-compat   (test for warnings,
line 300)
+FAIL: c-c++-common/Wstringop-truncation.c  -Wc++-compat  member array (test
for warnings, line 302)
+FAIL: c-c++-common/Wstringop-truncation.c  -Wc++-compat   (test for warnings,
line 373)
+FAIL: c-c++-common/Wstringop-truncation.c  -Wc++-compat   (test for warnings,
line 429)
+FAIL: c-c++-common/Wstringop-truncation.c  -Wc++-compat   (test for warnings,
line 430)
+FAIL: gcc.dg/Warray-bounds-45.c  (test for warnings, line 71)
+FAIL: gcc.dg/Warray-bounds-45.c  (test for warnings, line 72)
+FAIL: gcc.dg/Warray-bounds-45.c  (test for warnings, line 76)
+FAIL: gcc.dg/Warray-bounds-45.c  (test for warnings, line 77)
+FAIL: gcc.dg/Warray-bounds-45.c  (test for warnings, line 221)
+FAIL: gcc.dg/Warray-bounds-59.c (test for excess errors)
+FAIL: gcc.dg/Wstringop-overflow-39.c  (test for warnings, line 15)
+FAIL: gcc.dg/Wstringop-overflow-75.c note (test for warnings, line 74)
+FAIL: gcc.dg/Wstringop-overflow-75.c  (test for warnings, line 85)
+FAIL: gcc.dg/Wstringop-overflow.c  (test for warnings, line 124)
+FAIL: gcc.dg/Wstringop-overflow.c  (test for warnings, line 125)
+FAIL: gcc.dg/Wstringop-overflow.c  (test for warnings, line 126)
+FAIL: gcc.dg/Wstringop-overflow.c  (test for warnings, line 127)
+FAIL: gcc.dg/Wstringop-overflow.c  (test for warnings, line 128)
+FAIL: gcc.dg/Wstringop-overflow.c  (test for warnings, line 130)
+FAIL: gcc.dg/Wstringop-overflow.c  (test for warnings, line 131)
+FAIL: gcc.dg/Wstringop-truncation-3.c  (test for warnings, line 51)
+FAIL: gcc.dg/Wstringop-truncation-5.c  (test for bogus messages, line 34)
+FAIL: gcc.dg/Wstringop-truncation-5.c (test for excess errors)
+FAIL: gcc.dg/Wstringop-truncation.c  (test for warnings, line 26)
+FAIL: gcc.dg/Wstringop-truncation.c  (test for warnings, line 34)
+FAIL: gcc.dg/Wstringop-truncation.c  (test for warnings, line 116)
+FAIL: gcc.dg/builtin-stringop-chk-9.c  (test for warnings, line 85)
+FAIL: gcc.dg/builtin-stringop-chk-9.c  (test for warnings, line 98)
+FAIL: gcc.dg/builtin-stringop-chk-9.c  (test for warnings, line 125)
+FAIL: gcc.dg/builtin-stringop-chk-9.c  (test for warnings, line 133)
+FAIL: gcc.dg/pr81345.c  (test for warnings, line 16)
 XPASS: gcc.dg/guality/example.c   -O0  execution test
 XPASS: gcc.dg/guality/example.c  -Og -DPREVENT_OPTIMIZATION  execution test
 XPASS: gcc.dg/guality/guality.c   -O0  execution test
@@ -145,13 +232,30 @@
 FAIL: gcc.dg/guality/sra-1.c   -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects  -DPREVENT_OPTIMIZATION line 43 a.j == 14
 FAIL: gcc.dg/guality/vla-1.c   -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects  -DPREVENT_OPTIMIZATION line 24 i == 5
 FAIL: gcc.dg/guality/vla-1.c   -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects  -DPREVENT_OPTIMIZATION line 24 sizeof (a) == 17 * sizeof
(short)
+FAIL: gcc.dg/tree-ssa/builtin-sprintf-warn-14.c  (test for warnings, line 87)
+FAIL: gcc.dg/tree-ssa/builtin-sprintf-warn-14.c  (test for warnings, line 91)
+FAIL: gcc.dg/tree-ssa/builtin-sprintf-warn-14.c  (test for warnings, line 95)
+FAIL: gcc.dg/tree-ssa/builtin-sprintf-warn-14.c  (test for warnings, line 96)
+FAIL: gcc.dg/tree-ssa/builtin-sprintf-warn-14.c  (test for warnings, line 99)
+FAIL: gcc.dg/tree-ssa/builtin-sprintf-warn-14.c  (test for warnings, line 103)
+FAIL: gcc.dg/tree-ssa/builtin-sprintf-warn-14.c  (test for warnings, line 107)
+FAIL: gcc.dg/tree-ssa/builtin-sprintf-warn-14.c  (test for warnings, line 108)
+FAIL: gcc.dg/tree-ssa/builtin-sprintf-warn-14.c  (test for warnings, line 111)
+FAIL: gcc.dg/tree-ssa/builtin-sprintf-warn-14.c  (test for warnings, line 115)
+FAIL: gcc.dg/tree-ssa/builtin-sprintf-warn-14.c  (test for warnings, line 119)
+FAIL: gcc.dg/tree-ssa/builtin-sprintf-warn-14.c  (test for warnings, line 120)
+FAIL: gcc.dg/tree-ssa/builtin-sprintf-warn-14.c  (test for warnings, line 131)
+FAIL: gcc.dg/tree-ssa/builtin-sprintf-warn-14.c (test for excess errors)
+FAIL: gcc.dg/tree-ssa/builtin-sprintf-warn-29.c  (test for bogus messages,
line 84)
+FAIL: gcc.dg/tree-ssa/loadpre6.c scan-tree-dump-times pre "Insertions: 1" 1
+FAIL: gcc.dg/tree-ssa/pr21294.c scan-tree-dump-times vrp1 "Folding predicate"
1
 FAIL: gcc.target/i386/pr43644-2.c scan-assembler-times movq 1
 FAIL: gcc.target/i386/pr82580.c scan-assembler-not \\\\mmovzb

                === gcc Summary ===

-# of expected passes           195982
-# of unexpected failures       107
+# of expected passes           195929
+# of unexpected failures       162
 # of unexpected successes      19
 # of expected failures         1542
 # of unsupported tests         2865

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/112266] `constcall(a)` and `constcall(&a->b[0])` is not being optimized to one call
  2023-10-28 18:34 [Bug tree-optimization/112266] New: `constcall(a)` and `constcall(&a->b[0])` is not being optimized to one call pinskia at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-10-30 14:08 ` rguenth at gcc dot gnu.org
@ 2023-10-30 19:15 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-30 19:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #2)
> Wheeeeee - late diagnostic fallout galore!  Putting on hold.

I was expecting that. Many of the diagnostic for strings and array bounds, etc.
depend on the original form from the front-end and not a canonical form .

THough I see:
+FAIL: g++.dg/tree-prof/devirt.C scan-tree-dump-times tracer "folding virtual
function call to virtual unsigned int mozPersonalDictionary::_ZThn16" 1


Which is a missed optimization with respect to the devirtualizer depending on
the address form in gimple ...


On the other non-diagnostic issues:

+FAIL: gcc.dg/tree-ssa/pr21294.c scan-tree-dump-times vrp1 "Folding predicate"
1
This just fre now can optimize away the comparison too so disabling fre is
needed now

+FAIL: gcc.dg/tree-ssa/loadpre6.c scan-tree-dump-times pre "Insertions: 1" 1

Most likely a canonical form change.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-10-30 19:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-28 18:34 [Bug tree-optimization/112266] New: `constcall(a)` and `constcall(&a->b[0])` is not being optimized to one call pinskia at gcc dot gnu.org
2023-10-30 13:27 ` [Bug tree-optimization/112266] " rguenth at gcc dot gnu.org
2023-10-30 14:06 ` rguenth at gcc dot gnu.org
2023-10-30 14:08 ` rguenth at gcc dot gnu.org
2023-10-30 19:15 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).