[go: nahoru, domu]

Bug 103386 - -floop-nest-optimize -floop-interchange -fgraphite-identity miscompiles gcc (lra)
Summary: -floop-nest-optimize -floop-interchange -fgraphite-identity miscompiles gcc (...
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 11.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks: graphite
  Show dependency treegraph
 
Reported: 2021-11-23 15:06 UTC by mittorn
Modified: 2024-03-14 23:01 UTC (History)
0 users

See Also:
Host:
Target: aarch64
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-11-23 00:00:00


Attachments
pgo build logs and system environment (323.50 KB, application/x-tar)
2021-11-23 15:06 UTC, mittorn
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mittorn 2021-11-23 15:06:37 UTC
Created attachment 51862 [details]
pgo build logs and system environment

This result in failed conftest binary returning nonzero status when trying to build libgomp.
Simple program to reproduce conftest behaviour:

int main()
{
return 0;
}

stage1 makes bad assembly on it:

        .cfi_startproc
        stp     x0, x1, [sp, -32]!
        .cfi_def_cfa_offset 32
        .cfi_offset 0, -32
        .cfi_offset 1, -24
        stp     x2, x3, [sp, 16]
        .cfi_offset 2, -16
        .cfi_offset 3, -8
        mov     w0, 0
        ldp     x2, x3, [sp, 16]
        ldp     x0, x1, [sp], 32
        .cfi_restore 1
        .cfi_restore 0
        .cfi_restore 2
        .cfi_restore 3
        .cfi_def_cfa_offset 0
        ret
        .cfi_endproc

instead of this one:
        .cfi_startproc
        mov     w0, 0
        ret
        .cfi_endproc


after dumping RTL stages, i found this (source files are identical, second is stage1):

 ~ # diff 1.c.292r.reload 2.c.292r.reload
7a8,12
> New elimination table:
> Can eliminate 65 to 31 (offset=32, prev_offset=0)
> Can eliminate 65 to 29 (offset=32, prev_offset=0)
> Can eliminate 64 to 31 (offset=32, prev_offset=0)
> Can eliminate 64 to 29 (offset=32, prev_offset=0)
51,54c56,59
< Can eliminate 65 to 31 (offset=0, prev_offset=0)
< Can eliminate 65 to 29 (offset=0, prev_offset=0)
< Can eliminate 64 to 31 (offset=0, prev_offset=0)
< Can eliminate 64 to 29 (offset=0, prev_offset=0)
---
> Can eliminate 65 to 31 (offset=32, prev_offset=32)
> Can eliminate 65 to 29 (offset=32, prev_offset=0)
> Can eliminate 64 to 31 (offset=32, prev_offset=32)
> Can eliminate 64 to 29 (offset=32, prev_offset=0)
81c86
<         (const_int 0 [0])) "1.c":3:8 52 {*movsi_aarch64}
---
>         (const_int 0 [0])) "2.c":3:8 52 {*movsi_aarch64}
83c88
< (insn 13 5 15 2 (use (reg/i:SI 0 x0)) "1.c":4:1 -1
---
> (insn 13 5 15 2 (use (reg/i:SI 0 x0)) "2.c":4:1 -1


Full build tree temporary placed here:
http://mittorn.mentality.rip/
needed log and environment info in attachment
Comment 1 Andrew Pinski 2021-11-23 18:30:01 UTC
What GCC are you starting with?
Because you are building stage 1 compiler with "-O3 -ftree-vectorize -fomit-frame-pointer -mcpu=neoverse-n1 -mtune=neoverse-n1 -fno-plt -fipa-pta -funsafe-math-optimizations -funsafe-loop-optimizations -fdevirtualize-at-ltrans -floop-nest-optimize -fgraphite-identity -floop-interchange"

I think both "-fipa-pta" and "-fgraphite-identity" have known issues which could be causing issues here.  Plus GCC is not normally compiled with "-funsafe-math-optimizations" or "-funsafe-loop-optimizations".
Comment 2 mittorn 2021-11-24 16:57:26 UTC
Removing -floop-nest-optimize -floop-interchange -fgraphite-identity fixes build, but removing only -fgraphite-identity not