public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/104839] New: ppc64 regression of GCC 12: conditional long += long becomes unconditional SUBFC
@ 2022-03-08 11:31 vstinner at redhat dot com
  2022-03-08 11:34 ` [Bug c/104839] " vstinner at redhat dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: vstinner at redhat dot com @ 2022-03-08 11:31 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104839
           Summary: ppc64 regression of GCC 12: conditional long += long
                    becomes unconditional SUBFC
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vstinner at redhat dot com
  Target Milestone: ---

Created attachment 52583
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52583&action=edit
bug4.c: reproducer

When attached bug4.c is built on ppc64 with -O1, it returns 1 (bug). With -O0,
it returns 0 (ok), as expected.

$ gcc bug4.c -o bug -O1 && ./bug; echo $?
1
$ gcc bug4.c -o bug -O0 && ./bug; echo $?
0
$ uname -m
ppc64le

On x86-64, it returns 0 (ok) with -O0 and -02 as expected.

If you replace "long t_5 = i" with "int t_5 = i", it works as expected: a
conditional machine code is generated for the conditional "t_5 += shape" C
code.

--

The reproducer comes from this Cython bug:
https://bugzilla.redhat.com/show_bug.cgi?id=2045160

Cython compiles reproducer.pyx as ~23 000 lines of C code. The bug is in the
generated __pyx_pf_11reproducer2_get_schar() function.

Extract of the original code:
---
  __pyx_t_5 = __pyx_v_i;
  __pyx_t_6 = __pyx_v_j;
  __pyx_t_7 = -1;
  if (__pyx_t_5 < 0) {
    __pyx_t_5 += __pyx_v_buf.shape[0];
    if (unlikely(__pyx_t_5 < 0)) __pyx_t_7 = 0;
  } else if (unlikely(__pyx_t_5 >= __pyx_v_buf.shape[0])) __pyx_t_7 = 0;
  if (__pyx_t_6 < 0) {
    __pyx_t_6 += __pyx_v_buf.shape[1];
    if (unlikely(__pyx_t_6 < 0)) __pyx_t_7 = 1;
  } else if (unlikely(__pyx_t_6 >= __pyx_v_buf.shape[1])) __pyx_t_7 = 1;
  if (unlikely(__pyx_t_7 != -1)) {
    __Pyx_RaiseBufferIndexError(__pyx_t_7);
    __PYX_ERR(0, 140, __pyx_L1_error)
  }
---

It took me 2 days to simply the code and remove dependencies to Cython and
Python.

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

end of thread, other threads:[~2022-03-09  9:04 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-08 11:31 [Bug c/104839] New: ppc64 regression of GCC 12: conditional long += long becomes unconditional SUBFC vstinner at redhat dot com
2022-03-08 11:34 ` [Bug c/104839] " vstinner at redhat dot com
2022-03-08 13:10 ` [Bug target/104839] [12 Regression] " redi at gcc dot gnu.org
2022-03-08 13:17 ` redi at gcc dot gnu.org
2022-03-08 13:24 ` jakub at gcc dot gnu.org
2022-03-08 14:12 ` jakub at gcc dot gnu.org
2022-03-08 15:08 ` jakub at gcc dot gnu.org
2022-03-08 15:40 ` [Bug rtl-optimization/104839] " jakub at gcc dot gnu.org
2022-03-09  8:13 ` cvs-commit at gcc dot gnu.org
2022-03-09  8:17 ` jakub at gcc dot gnu.org
2022-03-09  9:04 ` vstinner at redhat dot com

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).