public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/112994] New: [Regression] Missed optimization for redundancy computation elimination because pattern is broken
@ 2023-12-13  5:46 652023330028 at smail dot nju.edu.cn
  2023-12-13  6:15 ` [Bug tree-optimization/112994] " pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: 652023330028 at smail dot nju.edu.cn @ 2023-12-13  5:46 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112994
           Summary: [Regression] Missed optimization for redundancy
                    computation elimination because pattern is broken
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 652023330028 at smail dot nju.edu.cn
  Target Milestone: ---

Hello, we noticed that maybe there is a missed optimization for redundancy
computation elimination.

Different from PR 111718, this missed optimization is a regression and not just
because of one missing pattern, but because of changes that broke patterns that
could have been eliminated:

The pattern /* Simplify (t * 2) / t) -> 2.  */ is broken.

https://godbolt.org/z/3er613Krx
int n,m;
void test(int a, int b){

    n=a+a;
    b=n;
    m=(n+b)/(b);
}

GCC (trunk) -O3:
test(int, int):
        lea     eax, [0+rdi*4]
        lea     ecx, [rdi+rdi]
        cdq
        mov     DWORD PTR n[rip], ecx
        idiv    ecx
        mov     DWORD PTR m[rip], eax
        ret

Expected code (GCC 11.4 -O3):
test(int, int):
        mov     DWORD PTR m[rip], 2
        add     edi, edi
        mov     DWORD PTR n[rip], edi
        ret

If our targeting is accurate, then this issue was caused by this commit:
https://github.com/gcc-mirror/gcc/commit/d846f225c25

Thank you very much for your time and effort! We look forward to hearing from
you.

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

end of thread, other threads:[~2023-12-15 12:40 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-13  5:46 [Bug tree-optimization/112994] New: [Regression] Missed optimization for redundancy computation elimination because pattern is broken 652023330028 at smail dot nju.edu.cn
2023-12-13  6:15 ` [Bug tree-optimization/112994] " pinskia at gcc dot gnu.org
2023-12-13  8:24 ` [Bug tree-optimization/112994] [12/13/14 Regression] " rguenth at gcc dot gnu.org
2023-12-13 14:26 ` jakub at gcc dot gnu.org
2023-12-13 15:13 ` jakub at gcc dot gnu.org
2023-12-13 16:02 ` jakub at gcc dot gnu.org
2023-12-13 18:15 ` jakub at gcc dot gnu.org
2023-12-13 18:16 ` jakub at gcc dot gnu.org
2023-12-14 10:58 ` cvs-commit at gcc dot gnu.org
2023-12-14 11:07 ` cvs-commit at gcc dot gnu.org
2023-12-15 12:40 ` jakub 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).