public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/115277] New: ICF needs to match loop bound estimates
@ 2024-05-29 14:11 hubicka at gcc dot gnu.org
  2024-05-29 14:16 ` [Bug middle-end/115277] [13/14/15 regression] " hubicka at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: hubicka at gcc dot gnu.org @ 2024-05-29 14:11 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115277
           Summary: ICF needs to match loop bound estimates
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hubicka at gcc dot gnu.org
  Target Milestone: ---

jan@localhost:/tmp> cat tt.c
int array[1000];
void
test (int a)
{
        if (__builtin_expect (a > 3, 1))
                return;
        for (int i = 0; i < a; i++)
                array[i]=i;
}
void
test2 (int a)
{
        if (__builtin_expect (a > 10, 1))
                return;
        for (int i = 0; i < a; i++)
                array[i]=i;
}
int
main()
{
        test(1);
        test(2);
        test(3);
        test2(10);
        if (array[9] != 9)
                __builtin_abort ();
        return 0;
}
jan@localhost:/tmp> gcc -O2 tt.c ; ./a.out
jan@localhost:/tmp> gcc -O3 tt.c ; ./a.out
Aborted (core dumped)


The problem here is that we do not match value ranges and thus we can end up
with different estimates on number of iterations.

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

* [Bug middle-end/115277] [13/14/15 regression] ICF needs to match loop bound estimates
  2024-05-29 14:11 [Bug middle-end/115277] New: ICF needs to match loop bound estimates hubicka at gcc dot gnu.org
@ 2024-05-29 14:16 ` hubicka at gcc dot gnu.org
  2024-05-30 12:53 ` jamborm at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: hubicka at gcc dot gnu.org @ 2024-05-29 14:16 UTC (permalink / raw)
  To: gcc-bugs

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

Jan Hubicka <hubicka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ICF needs to match loop     |[13/14/15 regression] ICF
                   |bound estimates             |needs to match loop bound
                   |                            |estimates

--- Comment #1 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
Reproduces on 14 and trunk. GCC 12 is not able to determine the loop bound
during early optimizations

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

* [Bug middle-end/115277] [13/14/15 regression] ICF needs to match loop bound estimates
  2024-05-29 14:11 [Bug middle-end/115277] New: ICF needs to match loop bound estimates hubicka at gcc dot gnu.org
  2024-05-29 14:16 ` [Bug middle-end/115277] [13/14/15 regression] " hubicka at gcc dot gnu.org
@ 2024-05-30 12:53 ` jamborm at gcc dot gnu.org
  2024-05-30 20:36 ` hubicka at ucw dot cz
  2024-05-31  6:36 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jamborm at gcc dot gnu.org @ 2024-05-30 12:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Martin Jambor <jamborm at gcc dot gnu.org> ---
(In reply to Jan Hubicka from comment #1)
> Reproduces on 14 and trunk. GCC 12 is not able to determine the loop bound
> during early optimizations

What about gcc 13?

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

* [Bug middle-end/115277] [13/14/15 regression] ICF needs to match loop bound estimates
  2024-05-29 14:11 [Bug middle-end/115277] New: ICF needs to match loop bound estimates hubicka at gcc dot gnu.org
  2024-05-29 14:16 ` [Bug middle-end/115277] [13/14/15 regression] " hubicka at gcc dot gnu.org
  2024-05-30 12:53 ` jamborm at gcc dot gnu.org
@ 2024-05-30 20:36 ` hubicka at ucw dot cz
  2024-05-31  6:36 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: hubicka at ucw dot cz @ 2024-05-30 20:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jan Hubicka <hubicka at ucw dot cz> ---
> What about gcc 13?
GCC 13 also misoptimizes.
Honza

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

* [Bug middle-end/115277] [13/14/15 regression] ICF needs to match loop bound estimates
  2024-05-29 14:11 [Bug middle-end/115277] New: ICF needs to match loop bound estimates hubicka at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-05-30 20:36 ` hubicka at ucw dot cz
@ 2024-05-31  6:36 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-31  6:36 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.4

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

end of thread, other threads:[~2024-05-31  6:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-29 14:11 [Bug middle-end/115277] New: ICF needs to match loop bound estimates hubicka at gcc dot gnu.org
2024-05-29 14:16 ` [Bug middle-end/115277] [13/14/15 regression] " hubicka at gcc dot gnu.org
2024-05-30 12:53 ` jamborm at gcc dot gnu.org
2024-05-30 20:36 ` hubicka at ucw dot cz
2024-05-31  6:36 ` rguenth 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).