public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada
@ 2020-06-08 16:40 marxin at gcc dot gnu.org
  2020-06-09  6:59 ` [Bug bootstrap/95582] " rguenth at gcc dot gnu.org
                   ` (23 more replies)
  0 siblings, 24 replies; 25+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-06-08 16:40 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95582
           Summary: [11 Regression] LTO lean + PGO bootstrap is broken in
                    Ada
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: bootstrap
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
                CC: rguenth at gcc dot gnu.org, rsandifo at gcc dot gnu.org
  Target Milestone: ---

Using:
../configure --enable-languages=c,c++,lto,ada --disable-multilib
--disable-libsanitizer --disable-werror --with-build-config=bootstrap-lto-lean
&& time nicem STAGE1_CFLAGS="-O2 -g" profiledbootstrap

I see the following ICE:

/home/mliska/Programming/gcc/objdir/./prev-gcc/lto1 -quiet -dumpbase
./gnatbind.ltrans2.ltrans -mtune=generic -march=x86-64 -g -g -g -O2 -O2 -O2
-Wextra -Wno-error=format-diag -Wpedantic -version -fno-openmp -fno-openacc
-fno-pie -fno-exceptions -fasynchronous-unwind-tables -fno-common -fprofile-use
-fltrans @/tmp/ccyXRzUi -o ./gnatbind.ltrans2.ltrans.s
GNU GIMPLE (GCC) version 11.0.0 20200608 (experimental) (x86_64-pc-linux-gnu)
        compiled by GNU C version 11.0.0 20200608 (experimental), GMP version
6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version none
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU GIMPLE (GCC) version 11.0.0 20200608 (experimental) (x86_64-pc-linux-gnu)
        compiled by GNU C version 11.0.0 20200608 (experimental), GMP version
6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version none
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
during GIMPLE pass: slp
../../gcc/ada/libgnat/s-os_lib.adb: In function
‘system__os_lib__normalize_pathname__missed_drive_letter’:
../../gcc/ada/libgnat/s-os_lib.adb:2133:7: internal compiler error: in
vect_init_pattern_stmt, at tree-vect-patterns.c:115
 2133 |       function Missed_Drive_Letter (Name : String) return Boolean is
      |       ^
0x774560 vect_init_pattern_stmt
        ../../gcc/tree-vect-patterns.c:115
0x1669c73 vect_set_pattern_stmt
        ../../gcc/tree-vect-patterns.c:133
0x1669c73 vect_mark_pattern_stmts
        ../../gcc/tree-vect-patterns.c:5248
0x1669c73 vect_pattern_recog_1
        ../../gcc/tree-vect-patterns.c:5364
0x1678d11 vect_pattern_recog(vec_info*)
        ../../gcc/tree-vect-patterns.c:5502
0xf0dc2a vect_slp_analyze_bb_1
        ../../gcc/tree-vect-slp.c:3097
0xf0dc2a vect_slp_bb_region
        ../../gcc/tree-vect-slp.c:3210
0xf0dc2a vect_slp_bb(basic_block_def*)
        ../../gcc/tree-vect-slp.c:3345
0xf0f91e execute
        ../../gcc/tree-vectorizer.c:1320

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

* [Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada
  2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
@ 2020-06-09  6:59 ` rguenth at gcc dot gnu.org
  2020-06-09  7:31 ` marxin at gcc dot gnu.org
                   ` (22 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-06-09  6:59 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.0
           Priority|P3                          |P1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Hmm, let's see if we get a non FDO testcase for this ...

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

* [Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada
  2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
  2020-06-09  6:59 ` [Bug bootstrap/95582] " rguenth at gcc dot gnu.org
@ 2020-06-09  7:31 ` marxin at gcc dot gnu.org
  2020-06-09  8:10 ` marxin at gcc dot gnu.org
                   ` (21 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-06-09  7:31 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |needs-bisection
   Last reconfirmed|                            |2020-06-09
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
I'm bisecting that right now..

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

* [Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada
  2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
  2020-06-09  6:59 ` [Bug bootstrap/95582] " rguenth at gcc dot gnu.org
  2020-06-09  7:31 ` marxin at gcc dot gnu.org
@ 2020-06-09  8:10 ` marxin at gcc dot gnu.org
  2020-06-09  8:14 ` marxin at gcc dot gnu.org
                   ` (20 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-06-09  8:10 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|needs-bisection             |

--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r11-990-gf8ca4dd657f767c5f7da335462a5150ced368697 which added a
new vectorizer opportunity, it's not a culprit revision.

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

* [Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada
  2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2020-06-09  8:10 ` marxin at gcc dot gnu.org
@ 2020-06-09  8:14 ` marxin at gcc dot gnu.org
  2020-06-09  8:25 ` marxin at gcc dot gnu.org
                   ` (19 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-06-09  8:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
Created attachment 48711
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48711&action=edit
Reproducer LTO bytecode

I think it would be easy to reproduce by LTO LTRANS .o file:

$ git co f8ca4dd657f767c5f7da335462a5150ced368697
$ make...
$ ./lto1 -fltrans /tmp/ada.o -quiet
during GIMPLE pass: slp
/home/mliska/Programming/gcc/gcc/ada/libgnat/s-os_lib.adb: In function
‘system__os_lib__normalize_pathname__missed_drive_letter’:
/home/mliska/Programming/gcc/gcc/ada/libgnat/s-os_lib.adb:2133:7: internal
compiler error: in vect_init_pattern_stmt, at tree-vect-patterns.c:115
0x1677dc4 vect_init_pattern_stmt
        ../../gcc/tree-vect-patterns.c:115
0x1677e26 vect_set_pattern_stmt
        ../../gcc/tree-vect-patterns.c:133
0x1687f34 vect_mark_pattern_stmts
        ../../gcc/tree-vect-patterns.c:5248
0x1688418 vect_pattern_recog_1
        ../../gcc/tree-vect-patterns.c:5364
0x168881d vect_pattern_recog(vec_info*)
        ../../gcc/tree-vect-patterns.c:5502
0xf1897a vect_slp_analyze_bb_1
        ../../gcc/tree-vect-slp.c:3097
0xf1897a vect_slp_bb_region
        ../../gcc/tree-vect-slp.c:3210
0xf1897a vect_slp_bb(basic_block_def*)
        ../../gcc/tree-vect-slp.c:3345
0xf1a67e execute
        ../../gcc/tree-vectorizer.c:1320
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

@Richi: Can you please reproduce that?

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

* [Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada
  2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2020-06-09  8:14 ` marxin at gcc dot gnu.org
@ 2020-06-09  8:25 ` marxin at gcc dot gnu.org
  2020-06-09  8:47 ` rguenth at gcc dot gnu.org
                   ` (18 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-06-09  8:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> ---
The problematic STMT is:
(gdb) p debug_gimple_stmt(orig_stmt_info->stmt)
_22 = (boolean) _21;

which comes from:

(gdb) p debug_bb(bb)
<bb 5> [count: 0]:
_8 ={v} __gnat_dir_separator;
# DEBUG SR.1076 => _8
_9 ={v} __gnat_dir_separator;
# DEBUG SR.1077 => _9
_10 = name.P_ARRAY;
_13 = (sizetype) _2;
_11 = VIEW_CONVERT_EXPR<UNSIGNED_16>(MEM[(character[D.8734:iftmp.827]
*)_10][_13 ...]{lb: _13 sz: 1});
# DEBUG SR.150 => _8
# DEBUG SR.151 => _9
MEM <character> [(character[1:2] *)&S343b] = _8;
MEM <character> [(character[1:2] *)&S343b + 1B] = _9;
_12 = VIEW_CONVERT_EXPR<UNSIGNED_16>(S343b.F);
_21 = _11 != _12;
_22 = (boolean) _21;

entire FN:

(gdb) p debug_function(current_function_decl, 0)
system__os_lib__normalize_pathname__missed_drive_letter (struct string___XUP
name)
{
  character SR.151;
  character SR.150;
  const struct string___XUB * name$P_BOUNDS;
  struct system__os_lib__normalize_pathname__missed_drive_letter__S343b___PAD
S343b;
  positive___XDLU_1__2147483647 _1;
  positive___XDLU_1__2147483647 _2;
  boolean _4;
  boolean _7;
  character _8;
  character _9;
  character[<PLACEHOLDER_EXPR sizetype>:<PLACEHOLDER_EXPR sizetype>] * _10;
  UNSIGNED_16 _11;
  UNSIGNED_16 _12;
  sizetype _13;
  boolean _14;
  bool _21;
  boolean _22;
  unsigned short patt_23;
  boolean patt_24;

  <bb 2> [count: 4805]:
  # DEBUG D#73 => name.P_BOUNDS
  # DEBUG name$P_BOUNDS => D#73
  _4 = system__os_lib__on_windows;
  if (_4 != 0)
    goto <bb 3>; [0.00%]
  else
    goto <bb 10>; [100.00%]

  <bb 10> [count: 4805]:

  <bb 7> [count: 4805]:
  goto <bb 6>; [100.00%]

  <bb 3> [count: 0]:
  _14 = system__os_lib__normalize_pathname__is_with_drive (name);
  if (_14 != 0)
    goto <bb 11>; [50.00%]
  else
    goto <bb 4>; [50.00%]

  <bb 11> [count: 0]:
  goto <bb 7>; [100.00%]

  <bb 4> [count: 0]:
  name$P_BOUNDS_16 = name.P_BOUNDS;
  _2 = name$P_BOUNDS_16->LB0;
  _1 = name$P_BOUNDS_16->UB0;
  if (_1 <= _2)
    goto <bb 9>; [50.00%]
  else
    goto <bb 5>; [50.00%]

  <bb 9> [count: 0]:
  goto <bb 6>; [100.00%]

  <bb 5> [count: 0]:
  _8 ={v} __gnat_dir_separator;
  # DEBUG SR.1076 => _8
  _9 ={v} __gnat_dir_separator;
  # DEBUG SR.1077 => _9
  _10 = name.P_ARRAY;
  _13 = (sizetype) _2;
  _11 = VIEW_CONVERT_EXPR<UNSIGNED_16>(MEM[(character[D.8734:iftmp.827]
*)_10][_13 ...]{lb: _13 sz: 1});
  # DEBUG SR.150 => _8
  # DEBUG SR.151 => _9
  MEM <character> [(character[1:2] *)&S343b] = _8;
  MEM <character> [(character[1:2] *)&S343b + 1B] = _9;
  _12 = VIEW_CONVERT_EXPR<UNSIGNED_16>(S343b.F);
  _21 = _11 != _12;
  _22 = (boolean) _21;

  <bb 6> [count: 4805]:
  # _7 = PHI <_22(5), 0(7), 1(9)>
  # DEBUG SR.1076 => NULL
  # DEBUG SR.1077 => NULL
  return _7;

}

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

* [Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada
  2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2020-06-09  8:25 ` marxin at gcc dot gnu.org
@ 2020-06-09  8:47 ` rguenth at gcc dot gnu.org
  2020-06-09  8:52 ` rguenth at gcc dot gnu.org
                   ` (17 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-06-09  8:47 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
I can reproduce it, yes.

_22 = (boolean) _21;

converts

 <ssa_name 0x7ffff62e3000
    type <boolean_type 0x7ffff6821b28 bool public unsigned QI
        size <integer_cst 0x7ffff680cca8 constant 8>
        unit-size <integer_cst 0x7ffff680ccc0 constant 1>
        align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff6821b28 precision:1 min <integer_cst 0x7ffff680cf00 0> max <integer_cst
0x7ffff680cf30 1>>
    visited
    def_stmt _21 = _11 != _12;
    version:21>

to

 <ssa_name 0x7ffff62e3048
    type <boolean_type 0x7ffff66133f0 boolean public unsigned QI
        size <integer_cst 0x7ffff680cca8 constant 8>
        unit-size <integer_cst 0x7ffff680ccc0 constant 1>
        align:8 warn_if_not_align:0 symtab:0 alias-set 23 canonical-type
0x7ffff66133f0 precision:8 min <integer_cst 0x7ffff6a057b0 0> max <integer_cst
0x7ffff6a05798 255> context <translation_unit_decl 0x7ffff68161e0
ada/b_gnatb.adb>
        pointer_to_this <pointer_type 0x7ffff66b2000>>
    visited
    def_stmt _22 = (boolean) _21;
    version:22
    ptr-info 0x7ffff6303cc0>

so Ada has BOOLEAN_TYPE with 8-bit precision and the middle-end
boolean_type_node is the one with 1-bit precision.

the origs stmt mask_precision is 16 coming from the _11 != _12 compare
with HImode operands.

A C or even GIMPLE testcase is difficult because we have no way to
declare that 8-bit BOOLEAN_TYPE.  But a fix for the ICE is likely
just to enhance VECT_SCALAR_BOOLEAN_TYPE.

We do have other tests like this in forwprop for example:

  /* Canonicalize _Bool == 0 and _Bool != 1 to _Bool != 0 by swapping edges. 
*/
  if ((TREE_CODE (TREE_TYPE (rhs1)) == BOOLEAN_TYPE
       || (INTEGRAL_TYPE_P (TREE_TYPE (rhs1))
           && TYPE_PRECISION (TREE_TYPE (rhs1)) == 1))

so we generally seem to assume BOOLEAN_TYPE has 1 bit precision?  CCing
Eric, eventually the bootstrap issue icks on a corner case of the Ada
FE and is a bug there.

The following would fix it in the vectorizer:

diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index 9bb82a546f6..8c8ec6cb111 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -1254,11 +1254,11 @@ struct gather_scatter_info {
    VECTOR_BOOLEAN_TYPE_P.  */

 #define VECT_SCALAR_BOOLEAN_TYPE_P(TYPE) \
-  (TREE_CODE (TYPE) == BOOLEAN_TYPE            \
-   || ((TREE_CODE (TYPE) == INTEGER_TYPE       \
-       || TREE_CODE (TYPE) == ENUMERAL_TYPE)   \
-       && TYPE_PRECISION (TYPE) == 1           \
-       && TYPE_UNSIGNED (TYPE)))
+  ((TREE_CODE (TYPE) == BOOLEAN_TYPE    \
+    || TREE_CODE (TYPE) == INTEGER_TYPE         \
+    || TREE_CODE (TYPE) == ENUMERAL_TYPE)\
+    && TYPE_PRECISION (TYPE) == 1       \
+    && TYPE_UNSIGNED (TYPE))

 static inline bool
 nested_in_vect_loop_p (class loop *loop, stmt_vec_info stmt_info)


Maybe Eric can also create something for gnat.dg?  What it needs is
an appearant opportunity in the basic-block thus the two adjacent
stores plus the compare and convert.  Eventually the dump of the
function Martin provided is enough to produce a testcase that ICEs?

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

* [Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada
  2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2020-06-09  8:47 ` rguenth at gcc dot gnu.org
@ 2020-06-09  8:52 ` rguenth at gcc dot gnu.org
  2020-06-09  9:40 ` ebotcazou at gcc dot gnu.org
                   ` (16 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-06-09  8:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
So Ada does

  /* In Ada, we use an unsigned 8-bit type for the default boolean type.  */
  boolean_type_node = make_unsigned_type (8);
  TREE_SET_CODE (boolean_type_node, BOOLEAN_TYPE);

but somehow in lto1 (or via pulling in C code into the LTRANS function?)
lto1 boolean_type_node is the 1-bit one.  So that's probably introducing
the mismatch (and eventually missed optimizations with -flto and Ada).

We're excempting boolean type from special streaming correctly:

    /* Skip boolean type and constants, they are frontend dependent.  */
    if (i != TI_BOOLEAN_TYPE
        && i != TI_BOOLEAN_FALSE
        && i != TI_BOOLEAN_TRUE

but of course then all middle-end (at lto1 time) generated expressions
with boolean type get to use the lto1 boolean_type_node which matches
that of the C frontend.

So a testcase will need both Ada and LTO to trigger the issue.

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

* [Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada
  2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2020-06-09  8:52 ` rguenth at gcc dot gnu.org
@ 2020-06-09  9:40 ` ebotcazou at gcc dot gnu.org
  2020-06-09 10:38 ` rguenther at suse dot de
                   ` (15 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2020-06-09  9:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
Well, the middle-end provides build_nonstandard_boolean_type to build boolean
types with arbitrary precision so it cannot assume they have precision 1.

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

* [Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada
  2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2020-06-09  9:40 ` ebotcazou at gcc dot gnu.org
@ 2020-06-09 10:38 ` rguenther at suse dot de
  2020-06-09 11:23 ` ebotcazou at gcc dot gnu.org
                   ` (14 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: rguenther at suse dot de @ 2020-06-09 10:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from rguenther at suse dot de <rguenther at suse dot de> ---
On Tue, 9 Jun 2020, ebotcazou at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582
> 
> --- Comment #8 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> Well, the middle-end provides build_nonstandard_boolean_type to build boolean
> types with arbitrary precision so it cannot assume they have precision 1.

Yeah, that was for vector components.  Not that I like it much.  Can
the middle-end assume that the Ada boolean types only contain 0 or 1
or are there other values that are supposed to be well-defined
true or false values?

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

* [Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada
  2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2020-06-09 10:38 ` rguenther at suse dot de
@ 2020-06-09 11:23 ` ebotcazou at gcc dot gnu.org
  2020-08-27 12:40 ` marxin at gcc dot gnu.org
                   ` (13 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2020-06-09 11:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> Yeah, that was for vector components.  Not that I like it much.  Can
> the middle-end assume that the Ada boolean types only contain 0 or 1
> or are there other values that are supposed to be well-defined
> true or false values?

The only well-defined values are 0 and 1, but all the bits up to the precision
need to be preserved in "nonlogical contexts".  So it's a standard boolean type
in "logical contexts" (with binary logic) and an integral type with precision 8
in "nonlogical contexts", the possibly issues arising of course at the
transition.

In practice this works fine without special handling in almost all cases, you
just need to be careful when you're manipulating bit patterns.

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

* [Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada
  2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2020-06-09 11:23 ` ebotcazou at gcc dot gnu.org
@ 2020-08-27 12:40 ` marxin at gcc dot gnu.org
  2020-08-27 12:55 ` rguenth at gcc dot gnu.org
                   ` (12 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-08-27 12:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Martin Liška <marxin at gcc dot gnu.org> ---
Is there any progress about this PR? It's still blocking Ada bootstrap.

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

* [Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada
  2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
                   ` (10 preceding siblings ...)
  2020-08-27 12:40 ` marxin at gcc dot gnu.org
@ 2020-08-27 12:55 ` rguenth at gcc dot gnu.org
  2020-08-27 13:24 ` marxin at gcc dot gnu.org
                   ` (11 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-08-27 12:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Martin Liška from comment #11)
> Is there any progress about this PR? It's still blocking Ada bootstrap.

Can you check the patch from comment#6?  I'm not 100% sure it's correct
but it can at most break Ada ... for Ada bool we'd not optimize it as
bool but as char or whatever size it has.  IIRC Ada has TYPE_MIN/MAX_VALUEs
that do not match the precision here but we might be happily add
true + true == 2 then.

As said, some Ada coverage would be nice.

I don't know enough about the mask_precision stuff to say whether a
different patch is better (drop the assert?  fail somewhere?).

Richard added the mask_precision field so maybe he can chime in?

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

* [Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada
  2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
                   ` (11 preceding siblings ...)
  2020-08-27 12:55 ` rguenth at gcc dot gnu.org
@ 2020-08-27 13:24 ` marxin at gcc dot gnu.org
  2020-10-02 13:05 ` marxin at gcc dot gnu.org
                   ` (10 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-08-27 13:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #12)
> (In reply to Martin Liška from comment #11)
> > Is there any progress about this PR? It's still blocking Ada bootstrap.
> 
> Can you check the patch from comment#6?

Yes, it works. I've been using it for some time in out gcc11 package.

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

* [Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada
  2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
                   ` (12 preceding siblings ...)
  2020-08-27 13:24 ` marxin at gcc dot gnu.org
@ 2020-10-02 13:05 ` marxin at gcc dot gnu.org
  2020-10-07 10:02 ` rguenth at gcc dot gnu.org
                   ` (9 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-10-02 13:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #14 from Martin Liška <marxin at gcc dot gnu.org> ---
> Yes, it works. I've been using it for some time in out gcc11 package.

PING

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

* [Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada
  2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
                   ` (13 preceding siblings ...)
  2020-10-02 13:05 ` marxin at gcc dot gnu.org
@ 2020-10-07 10:02 ` rguenth at gcc dot gnu.org
  2020-10-07 11:42 ` rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-10-07 10:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #15 from Richard Biener <rguenth at gcc dot gnu.org> ---
The patch causes g++.dg/vect/simd-bool-comparison-1.cc to FAIL because
it will result in signed BOOLEAN_TYPEs with precision 1 rejected.  Those we
use for build_nonstandard_boolean_type via

#0  0x0000000001b93458 in build_truth_vector_type_for_mode (nunits=...,
mask_mode=E_DImode) at /home/rguenther/src/gcc3/gcc/tree.c:10931
#1  0x0000000001b935a2 in build_truth_vector_type_for (vectype=<vector_type
0x7ffff69c0bd0>) at /home/rguenther/src/gcc3/gcc/tree.c:10949
#2  0x0000000001b96175 in truth_type_for (type=<vector_type 0x7ffff69c0bd0>) at
/home/rguenther/src/gcc3/gcc/tree.c:11764
#3  0x0000000001ae92b6 in get_mask_type_for_scalar_type (vinfo=0x3beccd0,
scalar_type=<boolean_type 0x7ffff682bb28 bool>, group_size=0)
    at /home/rguenther/src/gcc3/gcc/tree-vect-stmts.c:11137
#4  0x00000000028cfaee in vect_recog_mask_conversion_pattern (vinfo=0x3beccd0,
stmt_vinfo=0x3da6ae0, type_out=0x7fffffffc320)
    at /home/rguenther/src/gcc3/gcc/tree-vect-patterns.c:4354

which then causes the VECT_SCALAR_BOOLEAN_TYPE_P result to differ even for C++
at

#1  0x0000000001abfa11 in VECT_SCALAR_BOOLEAN_TYPE_P (TYPE=<boolean_type
0x7ffff69c01f8>) at /home/rguenther/src/gcc3/gcc/tree-vectorizer.h:1425
#2  0x0000000001ae41c1 in vect_is_simple_cond (cond=<ssa_name 0x7ffff69cd828
22>, vinfo=0x3beccd0, stmt_info=0x3da7410, slp_node=0x0, 
    comp_vectype=0x7fffffffbbe0, dts=0x7fffffffbbb0, vectype=<vector_type
0x7ffff68f7150>) at /home/rguenther/src/gcc3/gcc/tree-vect-stmts.c:9711
#3  0x0000000001ae49bf in vectorizable_condition (vinfo=0x3beccd0,
stmt_info=0x3da7410, gsi=0x0, vec_stmt=0x0, slp_node=0x0,
cost_vec=0x7fffffffc1b8)
    at /home/rguenther/src/gcc3/gcc/tree-vect-stmts.c:9876

now the Ada issue was about non-1 precision BOOLEAN_TYPE, so we could narrow
down the fix.  But then the question is why we allow signed 1-bit bools
but not signed 1-bit integers...

So I'm first re-testing

 #define VECT_SCALAR_BOOLEAN_TYPE_P(TYPE) \
-  (TREE_CODE (TYPE) == BOOLEAN_TYPE            \
-   || ((TREE_CODE (TYPE) == INTEGER_TYPE       \
-       || TREE_CODE (TYPE) == ENUMERAL_TYPE)   \
-       && TYPE_PRECISION (TYPE) == 1           \
-       && TYPE_UNSIGNED (TYPE)))
+  (INTEGRAL_TYPE_P (TYPE)               \
+   && TYPE_PRECISION (TYPE) == 1)

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

* [Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada
  2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
                   ` (14 preceding siblings ...)
  2020-10-07 10:02 ` rguenth at gcc dot gnu.org
@ 2020-10-07 11:42 ` rguenth at gcc dot gnu.org
  2020-10-07 12:38 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-10-07 11:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #16 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #15)
> The patch causes g++.dg/vect/simd-bool-comparison-1.cc to FAIL because
> it will result in signed BOOLEAN_TYPEs with precision 1 rejected.  Those we
> use for build_nonstandard_boolean_type via
> 
> #0  0x0000000001b93458 in build_truth_vector_type_for_mode (nunits=...,
> mask_mode=E_DImode) at /home/rguenther/src/gcc3/gcc/tree.c:10931
> #1  0x0000000001b935a2 in build_truth_vector_type_for (vectype=<vector_type
> 0x7ffff69c0bd0>) at /home/rguenther/src/gcc3/gcc/tree.c:10949
> #2  0x0000000001b96175 in truth_type_for (type=<vector_type 0x7ffff69c0bd0>)
> at /home/rguenther/src/gcc3/gcc/tree.c:11764
> #3  0x0000000001ae92b6 in get_mask_type_for_scalar_type (vinfo=0x3beccd0,
> scalar_type=<boolean_type 0x7ffff682bb28 bool>, group_size=0)
>     at /home/rguenther/src/gcc3/gcc/tree-vect-stmts.c:11137
> #4  0x00000000028cfaee in vect_recog_mask_conversion_pattern
> (vinfo=0x3beccd0, stmt_vinfo=0x3da6ae0, type_out=0x7fffffffc320)
>     at /home/rguenther/src/gcc3/gcc/tree-vect-patterns.c:4354
> 
> which then causes the VECT_SCALAR_BOOLEAN_TYPE_P result to differ even for
> C++
> at
> 
> #1  0x0000000001abfa11 in VECT_SCALAR_BOOLEAN_TYPE_P (TYPE=<boolean_type
> 0x7ffff69c01f8>) at /home/rguenther/src/gcc3/gcc/tree-vectorizer.h:1425
> #2  0x0000000001ae41c1 in vect_is_simple_cond (cond=<ssa_name 0x7ffff69cd828
> 22>, vinfo=0x3beccd0, stmt_info=0x3da7410, slp_node=0x0, 
>     comp_vectype=0x7fffffffbbe0, dts=0x7fffffffbbb0, vectype=<vector_type
> 0x7ffff68f7150>) at /home/rguenther/src/gcc3/gcc/tree-vect-stmts.c:9711
> #3  0x0000000001ae49bf in vectorizable_condition (vinfo=0x3beccd0,
> stmt_info=0x3da7410, gsi=0x0, vec_stmt=0x0, slp_node=0x0,
> cost_vec=0x7fffffffc1b8)
>     at /home/rguenther/src/gcc3/gcc/tree-vect-stmts.c:9876
> 
> now the Ada issue was about non-1 precision BOOLEAN_TYPE, so we could narrow
> down the fix.  But then the question is why we allow signed 1-bit bools
> but not signed 1-bit integers...
> 
> So I'm first re-testing
> 
>  #define VECT_SCALAR_BOOLEAN_TYPE_P(TYPE) \
> -  (TREE_CODE (TYPE) == BOOLEAN_TYPE            \
> -   || ((TREE_CODE (TYPE) == INTEGER_TYPE       \
> -       || TREE_CODE (TYPE) == ENUMERAL_TYPE)   \
> -       && TYPE_PRECISION (TYPE) == 1           \
> -       && TYPE_UNSIGNED (TYPE)))
> +  (INTEGRAL_TYPE_P (TYPE)               \
> +   && TYPE_PRECISION (TYPE) == 1)

FAIL: gcc.dg/vect/vect-cond-reduc-4.c -flto -ffat-lto-objects 
scan-tree-dump-times vect "LOOP VECTORIZED" 2
FAIL: gcc.dg/vect/vect-cond-reduc-4.c scan-tree-dump-times vect "LOOP
VECTORIZED" 2
FAIL: gcc.target/i386/avx512vl-pr88464-1.c scan-tree-dump-times vect "loop
vectorized using 32 byte vectors" 4
FAIL: gcc.target/i386/avx512vl-pr88464-1.c scan-tree-dump-times vect
"vectorized 1 loops in function" 4
FAIL: gcc.target/i386/avx512vl-pr88464-11.c scan-tree-dump-times vect "loop
vectorized using 16 byte vectors" 4
FAIL: gcc.target/i386/avx512vl-pr88464-11.c scan-tree-dump-times vect
"vectorized 1 loops in function" 4
FAIL: gcc.target/i386/avx512vl-pr88464-13.c scan-tree-dump-times vect "loop
vectorized using 32 byte vectors" 4
FAIL: gcc.target/i386/avx512vl-pr88464-13.c scan-tree-dump-times vect
"vectorized 1 loops in function" 4
FAIL: gcc.target/i386/avx512vl-pr88464-15.c scan-tree-dump-times vect "loop
vectorized using 16 byte vectors" 4
FAIL: gcc.target/i386/avx512vl-pr88464-15.c scan-tree-dump-times vect
"vectorized 1 loops in function" 4
FAIL: gcc.target/i386/avx512vl-pr88464-3.c scan-tree-dump-times vect "loop
vectorized using 16 byte vectors" 4
FAIL: gcc.target/i386/avx512vl-pr88464-3.c scan-tree-dump-times vect
"vectorized 1 loops in function" 4
FAIL: gcc.target/i386/avx512vl-pr88464-5.c scan-tree-dump-times vect "loop
vectorized using 32 byte vectors" 4
FAIL: gcc.target/i386/avx512vl-pr88464-5.c scan-tree-dump-times vect
"vectorized 1 loops in function" 4
FAIL: gcc.target/i386/avx512vl-pr88464-7.c scan-tree-dump-times vect "loop
vectorized using 16 byte vectors" 4
FAIL: gcc.target/i386/avx512vl-pr88464-7.c scan-tree-dump-times vect
"vectorized 1 loops in function" 4
FAIL: gcc.target/i386/avx512vl-pr88464-9.c scan-tree-dump-times vect "loop
vectorized using 32 byte vectors" 4
FAIL: gcc.target/i386/avx512vl-pr88464-9.c scan-tree-dump-times vect
"vectorized 1 loops in function" 4
FAIL: gcc.target/i386/pr87007-4.c scan-assembler-times vxorps[^\\n\\r]*xmm[0-9]
0
FAIL: gcc.target/i386/pr87007-5.c scan-assembler-times vxorps[^\\n\\r]*xmm[0-9]
0
FAIL: gcc.target/i386/vectorize10.c scan-tree-dump vect "vectorized 1 loops"

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

* [Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada
  2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
                   ` (15 preceding siblings ...)
  2020-10-07 11:42 ` rguenth at gcc dot gnu.org
@ 2020-10-07 12:38 ` rguenth at gcc dot gnu.org
  2020-12-07 10:05 ` marxin at gcc dot gnu.org
                   ` (6 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-10-07 12:38 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #17 from Richard Biener <rguenth at gcc dot gnu.org> ---
Same for

 #define VECT_SCALAR_BOOLEAN_TYPE_P(TYPE) \
-  (INTEGRAL_TYPE_P (TYPE)               \
-   && TYPE_PRECISION (TYPE) == 1)
+  ((TREE_CODE (TYPE) == BOOLEAN_TYPE           \
+    && TYPE_PRECISION (TYPE) == 1)             \
+   || ((TREE_CODE (TYPE) == INTEGER_TYPE       \
+       || TREE_CODE (TYPE) == ENUMERAL_TYPE)   \
+       && TYPE_PRECISION (TYPE) == 1           \
+       && TYPE_UNSIGNED (TYPE)))

so we do need to understand the Ada failure instead for which again I'm hoping
for a (LTO) testcase.  I'm not too familiar with the vector boolean pattern
stuff so I'm not the appropriate person to dig into this.

At least it seems this VECT_SCALAR_BOOLEAN_TYPE_P predicate is very much
fragile.

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

* [Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada
  2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
                   ` (16 preceding siblings ...)
  2020-10-07 12:38 ` rguenth at gcc dot gnu.org
@ 2020-12-07 10:05 ` marxin at gcc dot gnu.org
  2020-12-10 14:01 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-12-07 10:05 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |doko at debian dot org

--- Comment #18 from Martin Liška <marxin at gcc dot gnu.org> ---
*** Bug 98155 has been marked as a duplicate of this bug. ***

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

* [Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada
  2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
                   ` (17 preceding siblings ...)
  2020-12-07 10:05 ` marxin at gcc dot gnu.org
@ 2020-12-10 14:01 ` rguenth at gcc dot gnu.org
  2020-12-10 14:21 ` ebotcazou at gcc dot gnu.org
                   ` (4 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-12-10 14:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #19 from Richard Biener <rguenth at gcc dot gnu.org> ---
So I'm going to look at this again.  Some random thoughts on the Ada bools
though.  It would be nice if the Ada FE could leave boolean_type_node
untouched so that when the middle-end produces a compare to feed a branch
it does not end up using the 8-bit precision bool (because there's no out-of
range values to be considered for a compare result).  Basically keep the
Ada boolean "data type" separate from the middle-end boolean "logical type".

That said, I've ventured into the vectorizer detail failing recently and thus,
revisiting for a fix (or rather, [re-]understanding).

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

* [Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada
  2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
                   ` (18 preceding siblings ...)
  2020-12-10 14:01 ` rguenth at gcc dot gnu.org
@ 2020-12-10 14:21 ` ebotcazou at gcc dot gnu.org
  2020-12-11  8:23 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2020-12-10 14:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #20 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> So I'm going to look at this again.  Some random thoughts on the Ada bools
> though.  It would be nice if the Ada FE could leave boolean_type_node
> untouched so that when the middle-end produces a compare to feed a branch
> it does not end up using the 8-bit precision bool (because there's no out-of
> range values to be considered for a compare result).  Basically keep the
> Ada boolean "data type" separate from the middle-end boolean "logical type".

IIRC I tried that but this was pessimizing because of spurious conversions.

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

* [Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada
  2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
                   ` (19 preceding siblings ...)
  2020-12-10 14:21 ` ebotcazou at gcc dot gnu.org
@ 2020-12-11  8:23 ` rguenth at gcc dot gnu.org
  2020-12-11  9:10 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-12-11  8:23 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #21 from Richard Biener <rguenth at gcc dot gnu.org> ---
OK, so we recognize _22 = (boolean) _21 as bool pattern (convert from 1-bit
bool to 8-bit ada bool).  vect_recog_bool_pattern has some early-outs like

  if (CONVERT_EXPR_CODE_P (rhs_code)
      || rhs_code == VIEW_CONVERT_EXPR)
    {
      if (! INTEGRAL_TYPE_P (TREE_TYPE (lhs))
          || TYPE_PRECISION (TREE_TYPE (lhs)) == 1)
        return NULL;

which might be trying to rule out VECT_SCALAR_BOOLEAN_TYPE_P lhs.  At least
we're doing

      vectype = get_vectype_for_scalar_type (vinfo, TREE_TYPE (lhs));
      if (vectype == NULL_TREE)
        return NULL;

on it which will never return a VECTOR_BOOLEAN_TYPE_P and thus necessarily
trip the assert in vect_init_pattern_stmt [in case the stmt is supposed to
use mask precision].

Note the pattern as recognized doesn't necessarily do anything wrong - but
the meta recorded is inconsistent with it:

note:   using boolean precision 16 for _21 = _11 != _12;
note:   using boolean precision 16 for _22 = (boolean) _21;
note:   using boolean precision 16 for _7 = PHI <0(7), _22(5), 1(9)>

the function we trip on here doesn't contain any useful vectorization
opportunity but clearly the "pattern" is to have a "bool" compare
converted to Ada "data bool".

The conversion at hand is exposed by phiopt doing

-  if (_11 != _12)
-    goto <bb 6>; [66.00%]
-  else
-    goto <bb 7>; [34.00%]
-
-  <bb 6> [count: 0]:
+  _21 = _11 != _12;
+  _22 = (boolean) _21;

-  <bb 7> [count: 4858]:
-  # _7 = PHI <0(2), 0(3), 1(4), 0(5), 1(6)>
+  <bb 6> [count: 4858]:
+  # _7 = PHI <0(2), 0(3), 1(4), _22(5)>

where phiopt could have used the PHI arguments boolean type rather than
the LTO middle-end one also avoiding this ICE.  The interesting fact is
that the bool conversion is not useless (it changes precision) but
the IL verifier allows both types to be the result of the _11 != _12
compare (so we could add some fold pattern consuming those conversions
as well).

But this might make constructing a Ada testcase (with -flto of course)
possible by making sure there's a phiopt value-replacement opportunity
(we don't realize those "early" before LTO writeout) feeding bool
memory (so we have a real BB vectorization opportunity as well).

Now, I'm going to test

diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
index f2ce75aac3e..bf57c49bf04 100644
--- a/gcc/tree-vect-patterns.c
+++ b/gcc/tree-vect-patterns.c
@@ -4067,7 +4067,7 @@ vect_recog_bool_pattern (vec_info *vinfo,
       || rhs_code == VIEW_CONVERT_EXPR)
     {
       if (! INTEGRAL_TYPE_P (TREE_TYPE (lhs))
-         || TYPE_PRECISION (TREE_TYPE (lhs)) == 1)
+         || VECT_SCALAR_BOOLEAN_TYPE_P (TREE_TYPE (lhs)))
        return NULL;
       vectype = get_vectype_for_scalar_type (vinfo, TREE_TYPE (lhs));
       if (vectype == NULL_TREE)

which will definitely solve this instance of the ICE but of course other
fallout is unknown.  I'm leaving the PHI-OPT "optimization" opportunity
to the Ada folks if they care.  Likewise crafting a testcase from the
above [I'm going to think again about how to funnel non-standard bool
types to the GIMPLE FE - likely an additional attribute]

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

* [Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada
  2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
                   ` (20 preceding siblings ...)
  2020-12-11  8:23 ` rguenth at gcc dot gnu.org
@ 2020-12-11  9:10 ` cvs-commit at gcc dot gnu.org
  2020-12-11  9:49 ` rguenth at gcc dot gnu.org
  2021-01-06  9:21 ` cvs-commit at gcc dot gnu.org
  23 siblings, 0 replies; 25+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-12-11  9:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #22 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:fa4a8b6463e0dbc2a072fca835d28ae7a57849d5

commit r11-5925-gfa4a8b6463e0dbc2a072fca835d28ae7a57849d5
Author: Richard Biener <rguenther@suse.de>
Date:   Fri Dec 11 10:07:10 2020 +0100

    tree-optimization/95582 - fix vector pattern with bool conversions

    The pattern recognizer fends off against recognizing conversions
    from VECT_SCALAR_BOOLEAN_TYPE_P to precision one types but what
    it really needs to fend off is conversions between
    VECT_SCALAR_BOOLEAN_TYPE_P types - the Ada FE uses an 8 bit
    boolean type that satisfies this predicate.

    2020-12-11  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/95582
            * tree-vect-patterns.c (vect_recog_bool_pattern): Check
            for VECT_SCALAR_BOOLEAN_TYPE_P, not just precision one.

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

* [Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada
  2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
                   ` (21 preceding siblings ...)
  2020-12-11  9:10 ` cvs-commit at gcc dot gnu.org
@ 2020-12-11  9:49 ` rguenth at gcc dot gnu.org
  2021-01-06  9:21 ` cvs-commit at gcc dot gnu.org
  23 siblings, 0 replies; 25+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-12-11  9:49 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #23 from Richard Biener <rguenth at gcc dot gnu.org> ---
Verified that the LTO profiledbootstrap with Ada now works.

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

* [Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada
  2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
                   ` (22 preceding siblings ...)
  2020-12-11  9:49 ` rguenth at gcc dot gnu.org
@ 2021-01-06  9:21 ` cvs-commit at gcc dot gnu.org
  23 siblings, 0 replies; 25+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-06  9:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #24 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:c9ee9c1e3553247c776f33eb0fe0aadee094a192

commit r11-6500-gc9ee9c1e3553247c776f33eb0fe0aadee094a192
Author: Richard Biener <rguenther@suse.de>
Date:   Fri Dec 11 09:50:59 2020 +0100

    add signed_bool_precision attribute for GIMPLE FE use

    This adds __attribute__((signed_bool_precision(precision))) to be able
    to construct nonstandard boolean types which for the included testcase
    is needed to simulate Ada and LTO interaction (Ada uses a 8 bit
    precision boolean_type_node).  This will also be useful for vector
    unit testcases where we need to produce vector types with
    non-standard precision signed boolean type components.

    2021-01-06  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/95582
    gcc/c-family/
            * c-attribs.c (c_common_attribute_table): Add entry for
            signed_bool_precision.
            (handle_signed_bool_precision_attribute): New.

    gcc/testsuite/
            * gcc.dg/pr95582.c: New testcase.

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

end of thread, other threads:[~2021-01-06  9:21 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-08 16:40 [Bug bootstrap/95582] New: [11 Regression] LTO lean + PGO bootstrap is broken in Ada marxin at gcc dot gnu.org
2020-06-09  6:59 ` [Bug bootstrap/95582] " rguenth at gcc dot gnu.org
2020-06-09  7:31 ` marxin at gcc dot gnu.org
2020-06-09  8:10 ` marxin at gcc dot gnu.org
2020-06-09  8:14 ` marxin at gcc dot gnu.org
2020-06-09  8:25 ` marxin at gcc dot gnu.org
2020-06-09  8:47 ` rguenth at gcc dot gnu.org
2020-06-09  8:52 ` rguenth at gcc dot gnu.org
2020-06-09  9:40 ` ebotcazou at gcc dot gnu.org
2020-06-09 10:38 ` rguenther at suse dot de
2020-06-09 11:23 ` ebotcazou at gcc dot gnu.org
2020-08-27 12:40 ` marxin at gcc dot gnu.org
2020-08-27 12:55 ` rguenth at gcc dot gnu.org
2020-08-27 13:24 ` marxin at gcc dot gnu.org
2020-10-02 13:05 ` marxin at gcc dot gnu.org
2020-10-07 10:02 ` rguenth at gcc dot gnu.org
2020-10-07 11:42 ` rguenth at gcc dot gnu.org
2020-10-07 12:38 ` rguenth at gcc dot gnu.org
2020-12-07 10:05 ` marxin at gcc dot gnu.org
2020-12-10 14:01 ` rguenth at gcc dot gnu.org
2020-12-10 14:21 ` ebotcazou at gcc dot gnu.org
2020-12-11  8:23 ` rguenth at gcc dot gnu.org
2020-12-11  9:10 ` cvs-commit at gcc dot gnu.org
2020-12-11  9:49 ` rguenth at gcc dot gnu.org
2021-01-06  9:21 ` cvs-commit 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).