public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "zsojka at seznam dot cz" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/112760] [14 Regression] wrong code with -O2 -fno-dce -fno-guess-branch-probability -m8bit-idiv -mavx --param=max-cse-insns=0 and __builtin_add_overflow_p() Date: Wed, 29 Nov 2023 08:02:48 +0000 [thread overview] Message-ID: <bug-112760-4-Wnd61YzQN1@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-112760-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112760 --- Comment #1 from Zdenek Sojka <zsojka at seznam dot cz> --- Created attachment 56716 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56716&action=edit more complex testcase, with less compiler flags Attached a testcase that needs only -O2 -mavx; might be a different issue, though. $ x86_64-pc-linux-gnu-gcc -m32 -O2 -mavx testcase.c $ ./a.out Aborted $ diff -u a-testcase.GOOD.s a-testcase.BAD.s --- a-testcase.GOOD.s 2023-11-29 08:53:43.058791568 +0100 +++ a-testcase.BAD.s 2023-11-29 08:52:39.878792460 +0100 @@ -4,7 +4,7 @@ # compiled by GNU C version 14.0.0 20231128 (experimental), GMP version 6.3.0, MPFR version 4.2.1, MPC version 1.3.1, isl version isl-0.26-GMP # GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 -# options passed: -m32 -masm=intel -mtune=generic -march=x86-64 -O2 +# options passed: -m32 -mavx -masm=intel -mtune=generic -march=x86-64 -O2 .text .p2align 4 .globl foo0 @@ -37,19 +37,19 @@ rol ax, 8 # _5, # testcase.c:11: u64 u64_1 = __builtin_bswap16 (SHL (u64_0, u8_0)) % u16_0; div bx # u16_0 -# testcase.c:12: u8 u8_1 = __builtin_add_overflow_p (u8_0, u8_0, u8_0); - mov eax, ecx # u8_0, u8_0 # testcase.c:13: u32 u32_1 = foo0_u32_0 & u16_0; movzx ebx, bx # u16_0, u16_0 # testcase.c:12: u8 u8_1 = __builtin_add_overflow_p (u8_0, u8_0, u8_0); - add al, cl # u8_0, u8_0 + add al, al # u8_0, u8_0 +# testcase.c:14: u32 u32_2 = __builtin_sub_overflow_p (0, u64_1, (u8) 0); + movzx edx, dx # _6, tmp127 +# testcase.c:12: u8 u8_1 = __builtin_add_overflow_p (u8_0, u8_0, u8_0); setc al #, _15 # testcase.c:14: u32 u32_2 = __builtin_sub_overflow_p (0, u64_1, (u8) 0); xor ecx, ecx # tmp133 # testcase.c:13: u32 u32_1 = foo0_u32_0 & u16_0; and ebx, DWORD PTR foo0_u32_0 # u32_1, foo0_u32_0 # testcase.c:14: u32 u32_2 = __builtin_sub_overflow_p (0, u64_1, (u8) 0); - movzx edx, dx # _6, tmp127 sub ecx, edx # tmp132, _6 setb dl #, _18 and ecx, -256 # tmp132, Here, the problem is with: # testcase.c:12: u8 u8_1 = __builtin_add_overflow_p (u8_0, u8_0, u8_0); add al, al # u8_0, u8_0 due to the: -# testcase.c:12: u8 u8_1 = __builtin_add_overflow_p (u8_0, u8_0, u8_0); - mov eax, ecx # u8_0, u8_0 there is no "u8_0" in eax Maybe the compiler tries to use an AVX instruction, that is in the end not generated?
next prev parent reply other threads:[~2023-11-29 8:02 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-11-29 7:42 [Bug target/112760] New: " zsojka at seznam dot cz 2023-11-29 8:02 ` zsojka at seznam dot cz [this message] 2023-11-29 10:45 ` [Bug rtl-optimization/112760] " ubizjak at gmail dot com 2023-12-01 12:22 ` [Bug rtl-optimization/112760] [14 Regression] wrong code with -O2 -fno-dce -fno-guess-branch-probability -m8bit-idiv -mavx --param=max-cse-insns=0 and __builtin_add_overflow_p() since r14-5355 jakub at gcc dot gnu.org 2023-12-01 12:45 ` jakub at gcc dot gnu.org 2023-12-01 12:55 ` jakub at gcc dot gnu.org 2023-12-06 8:59 ` cvs-commit at gcc dot gnu.org 2023-12-06 9:01 ` jakub at gcc dot gnu.org 2023-12-06 18:33 ` pinskia at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-112760-4-Wnd61YzQN1@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).