public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/63665] New: [5 Regression] wrong code with signed overflow even with -fwrapv
@ 2014-10-28  9:04 zsojka at seznam dot cz
  2014-10-28  9:25 ` [Bug tree-optimization/63665] " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: zsojka at seznam dot cz @ 2014-10-28  9:04 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 63665
           Summary: [5 Regression] wrong code with signed overflow even
                    with -fwrapv
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zsojka at seznam dot cz

Created attachment 33826
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33826&action=edit
reduced testcase (from gcc.c-torture/execute/20040409-1.c)

Output:
$ gcc -O -fno-tree-ccp -fno-tree-fre -fwrapv testcase.c
$ ./a.out 
Aborted

In the assembly output, main() unconditionally calls abort().

The original testcase, gcc.c-torture/execute/20040409-1.c, fails with:
$ gcc -O2 -flto -fno-tree-ccp -fno-tree-copy-prop -fno-tree-fre 20040409-1.i
$ ./a.out 
Aborted

Tested revisions:
r216724 - FAIL
4_9 r216431 - OK
4_8 r216430 - OK


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

* [Bug tree-optimization/63665] [5 Regression] wrong code with signed overflow even with -fwrapv
  2014-10-28  9:04 [Bug tree-optimization/63665] New: [5 Regression] wrong code with signed overflow even with -fwrapv zsojka at seznam dot cz
@ 2014-10-28  9:25 ` rguenth at gcc dot gnu.org
  2014-10-28  9:43 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-10-28  9:25 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2014-10-28
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
   Target Milestone|---                         |5.0
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed, I'll have a look.


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

* [Bug tree-optimization/63665] [5 Regression] wrong code with signed overflow even with -fwrapv
  2014-10-28  9:04 [Bug tree-optimization/63665] New: [5 Regression] wrong code with signed overflow even with -fwrapv zsojka at seznam dot cz
  2014-10-28  9:25 ` [Bug tree-optimization/63665] " rguenth at gcc dot gnu.org
@ 2014-10-28  9:43 ` rguenth at gcc dot gnu.org
  2014-10-28 11:44 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-10-28  9:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
To better bisect this also use -fno-tree-copy-prop (which otherwise hides
this on the 4.9 branch for example).

It's forwprop that does the bogus transform on

  y_5 = -2147483648;
  _6 = y_5 + -2147483648;

which ends up calling fold_binary (NE_EXPR, y_5 + -2147483648, 0) which
computes it as 1.

8769          tree new_const = int_const_binop (reverse_op, const2, const1);

results in -2147483648(OVF) even though we have -fwrapv in effect which
the triggers

      /* If the constant operation overflowed this can be
         simplified as a comparison against INT_MAX/INT_MIN.  */
      if (TREE_OVERFLOW (new_const))
        {

without changing how we compute TREE_OVERFLOW it seems that this test needs
to be guarded with !TYPE_OVERFLOW_WRAPS ().


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

* [Bug tree-optimization/63665] [5 Regression] wrong code with signed overflow even with -fwrapv
  2014-10-28  9:04 [Bug tree-optimization/63665] New: [5 Regression] wrong code with signed overflow even with -fwrapv zsojka at seznam dot cz
  2014-10-28  9:25 ` [Bug tree-optimization/63665] " rguenth at gcc dot gnu.org
  2014-10-28  9:43 ` rguenth at gcc dot gnu.org
@ 2014-10-28 11:44 ` rguenth at gcc dot gnu.org
  2014-10-28 12:06 ` [Bug tree-optimization/63665] [4.8/4.9 " rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-10-28 11:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Tue Oct 28 11:42:43 2014
New Revision: 216781

URL: https://gcc.gnu.org/viewcvs?rev=216781&root=gcc&view=rev
Log:
2014-10-28  Richard Biener  <rguenther@suse.de>

    PR middle-end/63665
    * fold-const.c (fold_comparison): Properly guard simplifying
    against INT_MAX/INT_MIN with !TYPE_OVERFLOW_WRAPS.

    * gcc.dg/pr63665.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/pr63665.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/fold-const.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug tree-optimization/63665] [4.8/4.9 Regression] wrong code with signed overflow even with -fwrapv
  2014-10-28  9:04 [Bug tree-optimization/63665] New: [5 Regression] wrong code with signed overflow even with -fwrapv zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2014-10-28 11:44 ` rguenth at gcc dot gnu.org
@ 2014-10-28 12:06 ` rguenth at gcc dot gnu.org
  2014-10-28 12:54 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-10-28 12:06 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |5.0
   Target Milestone|5.0                         |4.8.4
            Summary|[5 Regression] wrong code   |[4.8/4.9 Regression] wrong
                   |with signed overflow even   |code with signed overflow
                   |with -fwrapv                |even with -fwrapv
      Known to fail|5.0                         |

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed on trunk.  Leaving open for a backport to 4.9/4.8.  Regression marker
so I don't miss it when doing the next batch of backports.


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

* [Bug tree-optimization/63665] [4.8/4.9 Regression] wrong code with signed overflow even with -fwrapv
  2014-10-28  9:04 [Bug tree-optimization/63665] New: [5 Regression] wrong code with signed overflow even with -fwrapv zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2014-10-28 12:06 ` [Bug tree-optimization/63665] [4.8/4.9 " rguenth at gcc dot gnu.org
@ 2014-10-28 12:54 ` rguenth at gcc dot gnu.org
  2014-11-26 11:43 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-10-28 12:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Latent issue.

pr45752.c:40:3: note: Load permutation 2 2 2 2 2 3 3 3 3 3 0 0 0 0 0 1 1 1 1 1
4 4 4 4 4

We have a SLP group size of 5 and computed an unroll factor of 2 (ok).  It
looks
to me that

Index: gcc/tree-vect-slp.c
===================================================================
--- gcc/tree-vect-slp.c (revision 216771)
+++ gcc/tree-vect-slp.c (working copy)

@@ -3041,6 +3041,7 @@ vect_transform_slp_perm_load (slp_tree n
                                          &number_of_mask_fixes, &mask_fixed,
                                          &needs_first_vector))
                return false;
+             gcc_assert (current_mask_element < 2 * nunits);
              mask[index++] = current_mask_element;

               if (index == nunits)

makes x86_64 ICE as well.  The issue is that we suddenly need to skip _two_
vectors in vect_get_mask_element which isn't implemented so we get
out-of-bound indexes.  Seems we need to iterate instead in which case
we will reject vectorization correctly with

pr45752.c:40:3: note: Load permutation 2 2 2 2 2 3 3 3 3 3 0 0 0 0 0 1 1 1 1 1
4 4 4 4 4
pr45752.c:40:3: note: permutation requires at least three vectors c_71 =
MEM[(unsigned int *)pInput2_135 + 8B];

pr45752.c:40:3: note: Build SLP failed: unsupported load permutation
*pOutput2_136 = _83;


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

* [Bug tree-optimization/63665] [4.8/4.9 Regression] wrong code with signed overflow even with -fwrapv
  2014-10-28  9:04 [Bug tree-optimization/63665] New: [5 Regression] wrong code with signed overflow even with -fwrapv zsojka at seznam dot cz
                   ` (4 preceding siblings ...)
  2014-10-28 12:54 ` rguenth at gcc dot gnu.org
@ 2014-11-26 11:43 ` rguenth at gcc dot gnu.org
  2014-11-26 13:16 ` [Bug tree-optimization/63665] [4.8 " rguenth at gcc dot gnu.org
  2014-11-26 13:17 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-11-26 11:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Wed Nov 26 11:42:44 2014
New Revision: 218078

URL: https://gcc.gnu.org/viewcvs?rev=218078&root=gcc&view=rev
Log:
2014-11-26  Richard Biener  <rguenther@suse.de>

    Backport from mainline
    2014-11-26  Richard Biener  <rguenther@suse.de>

    PR tree-optimization/62238
    * tree-predcom.c (ref_at_iteration): Unshare the expression
    before gimplifying it.

    * gcc.dg/torture/pr62238.c: New testcase.

    2014-11-25  Richard Biener  <rguenther@suse.de>

    PR tree-optimization/61927
    * tree-vect-loop.c (vect_analyze_loop_2): Revert ordering
    of group and pattern analysis to the one in GCC 4.8.

    2014-11-07  Richard Biener  <rguenther@suse.de>

    PR tree-optimization/63605
    * fold-const.c (fold_binary_loc): Properly use element_precision
    for types that may not be scalar.

    * gcc.dg/vect/pr63605.c: New testcase.

    2014-10-28  Richard Biener  <rguenther@suse.de>

    PR middle-end/63665
    * fold-const.c (fold_comparison): Properly guard simplifying
    against INT_MAX/INT_MIN with !TYPE_OVERFLOW_WRAPS.

    * gcc.dg/pr63665.c: New testcase.

Added:
    branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/pr63665.c
    branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/torture/pr62238.c
    branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/vect/pr63605.c
Modified:
    branches/gcc-4_9-branch/gcc/ChangeLog
    branches/gcc-4_9-branch/gcc/fold-const.c
    branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_9-branch/gcc/tree-predcom.c
    branches/gcc-4_9-branch/gcc/tree-vect-loop.c


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

* [Bug tree-optimization/63665] [4.8 Regression] wrong code with signed overflow even with -fwrapv
  2014-10-28  9:04 [Bug tree-optimization/63665] New: [5 Regression] wrong code with signed overflow even with -fwrapv zsojka at seznam dot cz
                   ` (5 preceding siblings ...)
  2014-11-26 11:43 ` rguenth at gcc dot gnu.org
@ 2014-11-26 13:16 ` rguenth at gcc dot gnu.org
  2014-11-26 13:17 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-11-26 13:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Wed Nov 26 13:15:16 2014
New Revision: 218079

URL: https://gcc.gnu.org/viewcvs?rev=218079&root=gcc&view=rev
Log:
2014-11-26  Richard Biener  <rguenther@suse.de>

    Backport from mainline
    2014-10-08  Richard Biener  <rguenther@suse.de>

    PR tree-optimization/61969
    * tree-nrv.c (pass_nrv::execute): Properly test for automatic
    variables.

    2014-08-15  Richard Biener  <rguenther@suse.de>

    PR tree-optimization/62031
    * tree-data-ref.c (dr_analyze_indices): Do not set
    DR_UNCONSTRAINED_BASE.
    (dr_may_alias_p): All indirect accesses have to go the
    formerly DR_UNCONSTRAINED_BASE path.
    * tree-data-ref.h (struct indices): Remove
    unconstrained_base member.
    (DR_UNCONSTRAINED_BASE): Remove.

    * gcc.dg/torture/pr62031.c: New testcase.

    2014-10-10  Richard Biener  <rguenther@suse.de>

    PR tree-optimization/63379
    * tree-vect-slp.c (vect_get_constant_vectors): Do not compute
    a neutral operand for min/max when it is not a reduction chain.

    * gcc.dg/vect/pr63379.c: New testcase.

    2014-11-07  Richard Biener  <rguenther@suse.de>

    PR tree-optimization/63605
    * fold-const.c (fold_binary_loc): Properly use element_precision
    for types that may not be scalar.

    * gcc.dg/vect/pr63605.c: New testcase.

    2014-10-28  Richard Biener  <rguenther@suse.de>

    PR middle-end/63665
    * fold-const.c (fold_comparison): Properly guard simplifying
    against INT_MAX/INT_MIN with !TYPE_OVERFLOW_WRAPS.

    * gcc.dg/pr63665.c: New testcase.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/pr63665.c
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/torture/pr62031.c
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/vect/pr63379.c
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/vect/pr63605.c
Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/fold-const.c
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_8-branch/gcc/tree-data-ref.c
    branches/gcc-4_8-branch/gcc/tree-data-ref.h
    branches/gcc-4_8-branch/gcc/tree-nrv.c
    branches/gcc-4_8-branch/gcc/tree-vect-slp.c


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

* [Bug tree-optimization/63665] [4.8 Regression] wrong code with signed overflow even with -fwrapv
  2014-10-28  9:04 [Bug tree-optimization/63665] New: [5 Regression] wrong code with signed overflow even with -fwrapv zsojka at seznam dot cz
                   ` (6 preceding siblings ...)
  2014-11-26 13:16 ` [Bug tree-optimization/63665] [4.8 " rguenth at gcc dot gnu.org
@ 2014-11-26 13:17 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-11-26 13:17 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.


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

end of thread, other threads:[~2014-11-26 13:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-28  9:04 [Bug tree-optimization/63665] New: [5 Regression] wrong code with signed overflow even with -fwrapv zsojka at seznam dot cz
2014-10-28  9:25 ` [Bug tree-optimization/63665] " rguenth at gcc dot gnu.org
2014-10-28  9:43 ` rguenth at gcc dot gnu.org
2014-10-28 11:44 ` rguenth at gcc dot gnu.org
2014-10-28 12:06 ` [Bug tree-optimization/63665] [4.8/4.9 " rguenth at gcc dot gnu.org
2014-10-28 12:54 ` rguenth at gcc dot gnu.org
2014-11-26 11:43 ` rguenth at gcc dot gnu.org
2014-11-26 13:16 ` [Bug tree-optimization/63665] [4.8 " rguenth at gcc dot gnu.org
2014-11-26 13:17 ` rguenth 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).