public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/103288] New: ice during GIMPLE pass: phiopt
@ 2021-11-16 21:38 dcb314 at hotmail dot com
  2021-11-16 21:43 ` [Bug tree-optimization/103288] [12 Regression] " pinskia at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: dcb314 at hotmail dot com @ 2021-11-16 21:38 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103288
           Summary: ice during GIMPLE pass: phiopt
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

Created attachment 51817
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51817&action=edit
C source code

For the attached C code, compiled with recent gcc trunk and
compiler flag -O2, does this:

$ /home/dcb/gcc/results/bin/gcc -w -O2 destDir/testFile.239.c 
destDir/testFile.239.c: In function ‘func_14’:
destDir/testFile.239.c:38:9: error: definition in block 6 does not dominate use
in block 5
   38 | int32_t func_14(uint64_t uli_8, int8_t c_9, int8_t c_10, uint64_t
uli_11)
      |         ^~~~~~~
for SSA_NAME: _102 in statement:
prephitmp_103 = PHI <_102(5), _102(6)>
PHI argument
_102
for PHI node
prephitmp_103 = PHI <_102(5), _102(6)>
during GIMPLE pass: phiopt

The bug first seems to occur sometime between git hash 2f3d43a35155685b
and 8a601f9bc45f9faa, a distance of 22 commits.

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

* [Bug tree-optimization/103288] [12 Regression] ice during GIMPLE pass: phiopt
  2021-11-16 21:38 [Bug c/103288] New: ice during GIMPLE pass: phiopt dcb314 at hotmail dot com
@ 2021-11-16 21:43 ` pinskia at gcc dot gnu.org
  2021-11-16 21:44 ` dcb314 at hotmail dot com
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-16 21:43 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ice during GIMPLE pass:     |[12 Regression] ice during
                   |phiopt                      |GIMPLE pass: phiopt
          Component|c                           |tree-optimization
                 CC|                            |pinskia at gcc dot gnu.org
   Target Milestone|---                         |12.0
           Keywords|                            |ice-on-valid-code

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Most likely caused by r12-5300-gf98f373dd822b35c .

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

* [Bug tree-optimization/103288] [12 Regression] ice during GIMPLE pass: phiopt
  2021-11-16 21:38 [Bug c/103288] New: ice during GIMPLE pass: phiopt dcb314 at hotmail dot com
  2021-11-16 21:43 ` [Bug tree-optimization/103288] [12 Regression] " pinskia at gcc dot gnu.org
@ 2021-11-16 21:44 ` dcb314 at hotmail dot com
  2021-11-16 21:52 ` dcb314 at hotmail dot com
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: dcb314 at hotmail dot com @ 2021-11-16 21:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from David Binderman <dcb314 at hotmail dot com> ---
Reduced C code seems to be

int ui_5;
long func_14_uli_8;
void func_14() {
        ui_5 &= (func_14_uli_8 ? 60 : ui_5) ? 5 : 0;
}

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

* [Bug tree-optimization/103288] [12 Regression] ice during GIMPLE pass: phiopt
  2021-11-16 21:38 [Bug c/103288] New: ice during GIMPLE pass: phiopt dcb314 at hotmail dot com
  2021-11-16 21:43 ` [Bug tree-optimization/103288] [12 Regression] " pinskia at gcc dot gnu.org
  2021-11-16 21:44 ` dcb314 at hotmail dot com
@ 2021-11-16 21:52 ` dcb314 at hotmail dot com
  2021-11-16 22:18 ` pinskia at gcc dot gnu.org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: dcb314 at hotmail dot com @ 2021-11-16 21:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from David Binderman <dcb314 at hotmail dot com> ---
(In reply to Andrew Pinski from comment #1)
> Most likely caused by r12-5300-gf98f373dd822b35c .

Strange. That git commit doesn't seem to be in the range of
git hashes I specified.

The one commit that does mention phi in that range is
b7a23949b0dcc4205fcc2be6b84b91441faa384d, by Aldy Hernandez.

I am unlikely to have the time to do a git bisect in the next 24
hours or so.

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

* [Bug tree-optimization/103288] [12 Regression] ice during GIMPLE pass: phiopt
  2021-11-16 21:38 [Bug c/103288] New: ice during GIMPLE pass: phiopt dcb314 at hotmail dot com
                   ` (2 preceding siblings ...)
  2021-11-16 21:52 ` dcb314 at hotmail dot com
@ 2021-11-16 22:18 ` pinskia at gcc dot gnu.org
  2021-11-16 22:47 ` pinskia at gcc dot gnu.org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-16 22:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
For me it was working at r12-5290-g074ee8d9a91d7 .

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

* [Bug tree-optimization/103288] [12 Regression] ice during GIMPLE pass: phiopt
  2021-11-16 21:38 [Bug c/103288] New: ice during GIMPLE pass: phiopt dcb314 at hotmail dot com
                   ` (3 preceding siblings ...)
  2021-11-16 22:18 ` pinskia at gcc dot gnu.org
@ 2021-11-16 22:47 ` pinskia at gcc dot gnu.org
  2021-11-16 22:50 ` pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-16 22:47 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-11-16
             Status|UNCONFIRMED                 |NEW

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Before phiopt, we have:
  if (func_14_uli_8.0_1 != 0)
    goto <bb 3>; [50.00%]
  else
    goto <bb 4>; [50.00%]

  <bb 3> [local count: 805306369]:
  _11 = pretmp_13 & 5;
  goto <bb 5>; [100.00%]

  <bb 4> [local count: 536870913]:
  if (pretmp_13 != 0)
    goto <bb 3>; [50.00%]
  else
    goto <bb 5>; [50.00%]

  <bb 5> [local count: 1073741824]:
  # prephitmp_12 = PHI <_11(3), 0(4)>

There must be a missing check (In reply to Andrew Pinski from comment #1)
> Most likely caused by r12-5300-gf98f373dd822b35c .

It actually worked at that point. r12-5301-g045206450386bcd77 did cause some IR
changes but I do think this just exposed a bug in r12-5300.

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

* [Bug tree-optimization/103288] [12 Regression] ice during GIMPLE pass: phiopt
  2021-11-16 21:38 [Bug c/103288] New: ice during GIMPLE pass: phiopt dcb314 at hotmail dot com
                   ` (4 preceding siblings ...)
  2021-11-16 22:47 ` pinskia at gcc dot gnu.org
@ 2021-11-16 22:50 ` pinskia at gcc dot gnu.org
  2021-11-16 23:12 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-16 22:50 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu.org

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #5)
> It actually worked at that point. r12-5301-g045206450386bcd77 did cause some
> IR changes but I do think this just exposed a bug in r12-5300.

Yes, if I revert either r12-5300 or r12-5301 the failure goes away.

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

* [Bug tree-optimization/103288] [12 Regression] ice during GIMPLE pass: phiopt
  2021-11-16 21:38 [Bug c/103288] New: ice during GIMPLE pass: phiopt dcb314 at hotmail dot com
                   ` (5 preceding siblings ...)
  2021-11-16 22:50 ` pinskia at gcc dot gnu.org
@ 2021-11-16 23:12 ` pinskia at gcc dot gnu.org
  2021-11-16 23:31 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-16 23:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #5)
> Before phiopt, we have:
>   if (func_14_uli_8.0_1 != 0)
>     goto <bb 3>; [50.00%]
>   else
>     goto <bb 4>; [50.00%]
> 
>   <bb 3> [local count: 805306369]:
>   _11 = pretmp_13 & 5;
>   goto <bb 5>; [100.00%]
> 
>   <bb 4> [local count: 536870913]:
>   if (pretmp_13 != 0)
>     goto <bb 3>; [50.00%]
>   else
>     goto <bb 5>; [50.00%]
> 
>   <bb 5> [local count: 1073741824]:
>   # prephitmp_12 = PHI <_11(3), 0(4)>

So the bug is inside value_replacement where we move the definition of _11 to
be inside bb 4:
(gdb) p debug_bb(cond_bb)
;; basic block 4, loop depth 0, count 536870913 (estimated locally), maybe hot
;;  prev block 3, next block 5, flags: (NEW, REACHABLE, VISITED)
;;  pred:       2 [50.0% (guessed)]  count:536870912 (estimated locally)
(FALSE_VALUE,EXECUTABLE)
_11 = pretmp_13 & 5;
if (pretmp_13 != 0)
  goto <bb 3>; [50.00%]
else
  goto <bb 5>; [50.00%]
;;  succ:       3 [50.0% (guessed)]  count:268435457 (estimated locally)
(TRUE_VALUE,EXECUTABLE)
;;              5 [50.0% (guessed)]  count:268435457 (estimated locally)
(FALSE_VALUE,EXECUTABLE)

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

* [Bug tree-optimization/103288] [12 Regression] ice during GIMPLE pass: phiopt
  2021-11-16 21:38 [Bug c/103288] New: ice during GIMPLE pass: phiopt dcb314 at hotmail dot com
                   ` (6 preceding siblings ...)
  2021-11-16 23:12 ` pinskia at gcc dot gnu.org
@ 2021-11-16 23:31 ` pinskia at gcc dot gnu.org
  2021-11-16 23:34 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-16 23:31 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This fixes the problem:
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index 6b22f6bedd4..d96ca690d2f 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -1462,6 +1462,9 @@ value_replacement (basic_block cond_bb, basic_block
middle_bb,
       prep_stmt[prep_cnt] = g;
     }

+  if (!single_pred_p (middle_bb))
+    return 0;
+
   /* Only transform if it removes the condition.  */
   if (!single_non_singleton_phi_for_edges (phi_nodes (gimple_bb (phi)), e0,
e1))
     return 0;


I still need to test it a little bit.

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

* [Bug tree-optimization/103288] [12 Regression] ice during GIMPLE pass: phiopt
  2021-11-16 21:38 [Bug c/103288] New: ice during GIMPLE pass: phiopt dcb314 at hotmail dot com
                   ` (7 preceding siblings ...)
  2021-11-16 23:31 ` pinskia at gcc dot gnu.org
@ 2021-11-16 23:34 ` pinskia at gcc dot gnu.org
  2021-11-17  0:13 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-16 23:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #8)
> I still need to test it a little bit.

I get no failures in tree-ssa.exp. Running a full bootstrap/test.

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

* [Bug tree-optimization/103288] [12 Regression] ice during GIMPLE pass: phiopt
  2021-11-16 21:38 [Bug c/103288] New: ice during GIMPLE pass: phiopt dcb314 at hotmail dot com
                   ` (8 preceding siblings ...)
  2021-11-16 23:34 ` pinskia at gcc dot gnu.org
@ 2021-11-17  0:13 ` pinskia at gcc dot gnu.org
  2021-11-17  7:47 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-17  0:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 51819
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51819&action=edit
Patch which is in testing

Patch is now in full testing.

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

* [Bug tree-optimization/103288] [12 Regression] ice during GIMPLE pass: phiopt
  2021-11-16 21:38 [Bug c/103288] New: ice during GIMPLE pass: phiopt dcb314 at hotmail dot com
                   ` (9 preceding siblings ...)
  2021-11-17  0:13 ` pinskia at gcc dot gnu.org
@ 2021-11-17  7:47 ` pinskia at gcc dot gnu.org
  2021-11-17  8:05 ` cvs-commit at gcc dot gnu.org
  2021-11-17  8:06 ` pinskia at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-17  7:47 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                URL|                            |https://gcc.gnu.org/piperma
                   |                            |il/gcc-patches/2021-Novembe
                   |                            |r/584675.html

--- Comment #11 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Patch submitted:
https://gcc.gnu.org/pipermail/gcc-patches/2021-November/584675.html

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

* [Bug tree-optimization/103288] [12 Regression] ice during GIMPLE pass: phiopt
  2021-11-16 21:38 [Bug c/103288] New: ice during GIMPLE pass: phiopt dcb314 at hotmail dot com
                   ` (10 preceding siblings ...)
  2021-11-17  7:47 ` pinskia at gcc dot gnu.org
@ 2021-11-17  8:05 ` cvs-commit at gcc dot gnu.org
  2021-11-17  8:06 ` pinskia at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-11-17  8:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:

https://gcc.gnu.org/g:1a15a91a0015208eafb797e4de1348c9877fd6d0

commit r12-5333-g1a15a91a0015208eafb797e4de1348c9877fd6d0
Author: Andrew Pinski <apinski@marvell.com>
Date:   Tue Nov 16 23:37:08 2021 +0000

    Fix PR 103288, ICE after PHI-OPT, move an assigment when still in use for
another bb

    The problem is r12-5300-gf98f373dd822b35c allows phiopt to recognize more
basic blocks
    but missed one location where phiopt could move an assignment from the
middle block
    to the non-middle one.  This patch fixes that.

    OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

            PR tree-optimization/103288

    gcc/ChangeLog:

            * tree-ssa-phiopt.c (value_replacement): Return early if middle
            block has more than one pred.

    gcc/testsuite/ChangeLog:

            * gcc.c-torture/compile/pr103288-1.c: New test.

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

* [Bug tree-optimization/103288] [12 Regression] ice during GIMPLE pass: phiopt
  2021-11-16 21:38 [Bug c/103288] New: ice during GIMPLE pass: phiopt dcb314 at hotmail dot com
                   ` (11 preceding siblings ...)
  2021-11-17  8:05 ` cvs-commit at gcc dot gnu.org
@ 2021-11-17  8:06 ` pinskia at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-17  8:06 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

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

--- Comment #13 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2021-11-17  8:06 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16 21:38 [Bug c/103288] New: ice during GIMPLE pass: phiopt dcb314 at hotmail dot com
2021-11-16 21:43 ` [Bug tree-optimization/103288] [12 Regression] " pinskia at gcc dot gnu.org
2021-11-16 21:44 ` dcb314 at hotmail dot com
2021-11-16 21:52 ` dcb314 at hotmail dot com
2021-11-16 22:18 ` pinskia at gcc dot gnu.org
2021-11-16 22:47 ` pinskia at gcc dot gnu.org
2021-11-16 22:50 ` pinskia at gcc dot gnu.org
2021-11-16 23:12 ` pinskia at gcc dot gnu.org
2021-11-16 23:31 ` pinskia at gcc dot gnu.org
2021-11-16 23:34 ` pinskia at gcc dot gnu.org
2021-11-17  0:13 ` pinskia at gcc dot gnu.org
2021-11-17  7:47 ` pinskia at gcc dot gnu.org
2021-11-17  8:05 ` cvs-commit at gcc dot gnu.org
2021-11-17  8:06 ` 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).