public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/113265] New: [Regression] Missed optimization for redundancy computation elimination may be due to constant propagation about 0 too late
@ 2024-01-08  8:25 652023330028 at smail dot nju.edu.cn
  2024-01-09  8:06 ` [Bug tree-optimization/113265] " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: 652023330028 at smail dot nju.edu.cn @ 2024-01-08  8:25 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113265
           Summary: [Regression] Missed optimization for redundancy
                    computation elimination may be due to constant
                    propagation about 0 too late
           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.

https://godbolt.org/z/drfejE5cP

int x,y,z;
void func(int a, int b){
    a=b-x;
    b=a;
    y=0;
    z=(y+a)/(-b);
}

GCC -O3 :
func(int, int):
        mov     ecx, DWORD PTR x[rip]
        mov     eax, esi
        mov     DWORD PTR y[rip], 0
        sub     eax, ecx
        sub     ecx, esi
        cdq
        idiv    ecx
        mov     DWORD PTR z[rip], eax
        ret

Earlier GCC versions get the expected optimizations:
Expected code (GCC 7.5):
func(int, int):
        mov     DWORD PTR y[rip], 0
        mov     DWORD PTR z[rip], -1
        ret

The following code is optimized by gcc as expected:
void func2(int a, int b){
    a=b-x;
    b=a;
    y=0;
    z=(0+a)/(-b);
}

Comparing the code for func and func2 and their ccp1(tree), we suspect that
this issue may be caused by too late propagation about y=0.

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

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

end of thread, other threads:[~2024-05-26  5:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-08  8:25 [Bug tree-optimization/113265] New: [Regression] Missed optimization for redundancy computation elimination may be due to constant propagation about 0 too late 652023330028 at smail dot nju.edu.cn
2024-01-09  8:06 ` [Bug tree-optimization/113265] " rguenth at gcc dot gnu.org
2024-01-09  8:16 ` rguenth at gcc dot gnu.org
2024-01-09  8:43 ` pinskia at gcc dot gnu.org
2024-01-09 22:55 ` [Bug tree-optimization/113265] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
2024-01-09 23:01 ` pinskia at gcc dot gnu.org
2024-03-07 20:52 ` law at gcc dot gnu.org
2024-05-26  5:43 ` [Bug tree-optimization/113265] [11/12/13/14/15 " pinskia at gcc dot gnu.org
2024-05-26  5:44 ` 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).