[Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada

2021-01-06 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582

--- Comment #24 from CVS Commits  ---
The master branch has been updated by Richard Biener :

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

commit r11-6500-gc9ee9c1e3553247c776f33eb0fe0aadee094a192
Author: Richard Biener 
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  

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.

[Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada

2020-12-11 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582

Richard Biener  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #23 from Richard Biener  ---
Verified that the LTO profiledbootstrap with Ada now works.

[Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada

2020-12-11 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582

--- Comment #22 from CVS Commits  ---
The master branch has been updated by Richard Biener :

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

commit r11-5925-gfa4a8b6463e0dbc2a072fca835d28ae7a57849d5
Author: Richard Biener 
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  

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

[Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada

2020-12-11 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582

Richard Biener  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  ---
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 ; [66.00%]
-  else
-goto ; [34.00%]
-
-   [count: 0]:
+  _21 = _11 != _12;
+  _22 = (boolean) _21;

-   [count: 4858]:
-  # _7 = PHI <0(2), 0(3), 1(4), 0(5), 1(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]

[Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada

2020-12-10 Thread ebotcazou at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582

--- Comment #20 from Eric Botcazou  ---
> 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.

[Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada

2020-12-10 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582

--- Comment #19 from Richard Biener  ---
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).

[Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada

2020-12-07 Thread marxin at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582

Martin Liška  changed:

   What|Removed |Added

 CC||doko at debian dot org

--- Comment #18 from Martin Liška  ---
*** Bug 98155 has been marked as a duplicate of this bug. ***

[Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada

2020-10-07 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582

Richard Biener  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #17 from Richard Biener  ---
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.

[Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada

2020-10-07 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582

--- Comment #16 from Richard Biener  ---
(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  0x01b93458 in build_truth_vector_type_for_mode (nunits=...,
> mask_mode=E_DImode) at /home/rguenther/src/gcc3/gcc/tree.c:10931
> #1  0x01b935a2 in build_truth_vector_type_for (vectype= 0x769c0bd0>) at /home/rguenther/src/gcc3/gcc/tree.c:10949
> #2  0x01b96175 in truth_type_for (type=)
> at /home/rguenther/src/gcc3/gcc/tree.c:11764
> #3  0x01ae92b6 in get_mask_type_for_scalar_type (vinfo=0x3beccd0,
> scalar_type=, group_size=0)
> at /home/rguenther/src/gcc3/gcc/tree-vect-stmts.c:11137
> #4  0x028cfaee in vect_recog_mask_conversion_pattern
> (vinfo=0x3beccd0, stmt_vinfo=0x3da6ae0, type_out=0x7fffc320)
> 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  0x01abfa11 in VECT_SCALAR_BOOLEAN_TYPE_P (TYPE= 0x769c01f8>) at /home/rguenther/src/gcc3/gcc/tree-vectorizer.h:1425
> #2  0x01ae41c1 in vect_is_simple_cond (cond= 22>, vinfo=0x3beccd0, stmt_info=0x3da7410, slp_node=0x0, 
> comp_vectype=0x7fffbbe0, dts=0x7fffbbb0, vectype= 0x768f7150>) at /home/rguenther/src/gcc3/gcc/tree-vect-stmts.c:9711
> #3  0x01ae49bf in vectorizable_condition (vinfo=0x3beccd0,
> stmt_info=0x3da7410, gsi=0x0, vec_stmt=0x0, slp_node=0x0,
> cost_vec=0x7fffc1b8)
> 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"

[Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada

2020-10-07 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582

--- Comment #15 from Richard Biener  ---
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  0x01b93458 in build_truth_vector_type_for_mode (nunits=...,
mask_mode=E_DImode) at /home/rguenther/src/gcc3/gcc/tree.c:10931
#1  0x01b935a2 in build_truth_vector_type_for (vectype=) at /home/rguenther/src/gcc3/gcc/tree.c:10949
#2  0x01b96175 in truth_type_for (type=) at
/home/rguenther/src/gcc3/gcc/tree.c:11764
#3  0x01ae92b6 in get_mask_type_for_scalar_type (vinfo=0x3beccd0,
scalar_type=, group_size=0)
at /home/rguenther/src/gcc3/gcc/tree-vect-stmts.c:11137
#4  0x028cfaee in vect_recog_mask_conversion_pattern (vinfo=0x3beccd0,
stmt_vinfo=0x3da6ae0, type_out=0x7fffc320)
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  0x01abfa11 in VECT_SCALAR_BOOLEAN_TYPE_P (TYPE=) at /home/rguenther/src/gcc3/gcc/tree-vectorizer.h:1425
#2  0x01ae41c1 in vect_is_simple_cond (cond=, vinfo=0x3beccd0, stmt_info=0x3da7410, slp_node=0x0, 
comp_vectype=0x7fffbbe0, dts=0x7fffbbb0, vectype=) at /home/rguenther/src/gcc3/gcc/tree-vect-stmts.c:9711
#3  0x01ae49bf in vectorizable_condition (vinfo=0x3beccd0,
stmt_info=0x3da7410, gsi=0x0, vec_stmt=0x0, slp_node=0x0,
cost_vec=0x7fffc1b8)
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)

[Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada

2020-10-02 Thread marxin at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582

--- Comment #14 from Martin Liška  ---
> Yes, it works. I've been using it for some time in out gcc11 package.

PING

[Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada

2020-08-27 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582

--- Comment #13 from Martin Liška  ---
(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.

[Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada

2020-08-27 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582

--- Comment #12 from Richard Biener  ---
(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?

[Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada

2020-08-27 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582

--- Comment #11 from Martin Liška  ---
Is there any progress about this PR? It's still blocking Ada bootstrap.

[Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada

2020-06-09 Thread ebotcazou at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582

--- Comment #10 from Eric Botcazou  ---
> 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.

[Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada

2020-06-09 Thread rguenther at suse dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582

--- Comment #9 from 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  ---
> 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?

[Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada

2020-06-09 Thread ebotcazou at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582

--- Comment #8 from Eric Botcazou  ---
Well, the middle-end provides build_nonstandard_boolean_type to build boolean
types with arbitrary precision so it cannot assume they have precision 1.

[Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada

2020-06-09 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582

--- Comment #7 from Richard Biener  ---
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.

[Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada

2020-06-09 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582

Richard Biener  changed:

   What|Removed |Added

 CC||ebotcazou at gcc dot gnu.org

--- Comment #6 from Richard Biener  ---
I can reproduce it, yes.

_22 = (boolean) _21;

converts

 
unit-size 
align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x76821b28 precision:1 min  max >
visited
def_stmt _21 = _11 != _12;
version:21>

to

 
unit-size 
align:8 warn_if_not_align:0 symtab:0 alias-set 23 canonical-type
0x766133f0 precision:8 min  max  context 
pointer_to_this >
visited
def_stmt _22 = (boolean) _21;
version:22
ptr-info 0x76303cc0>

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?

[Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada

2020-06-09 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582

--- Comment #5 from Martin Liška  ---
The problematic STMT is:
(gdb) p debug_gimple_stmt(orig_stmt_info->stmt)
_22 = (boolean) _21;

which comes from:

(gdb) p debug_bb(bb)
 [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(MEM[(character[D.8734:iftmp.827]
*)_10][_13 ...]{lb: _13 sz: 1});
# DEBUG SR.150 => _8
# DEBUG SR.151 => _9
MEM  [(character[1:2] *)] = _8;
MEM  [(character[1:2] *) + 1B] = _9;
_12 = VIEW_CONVERT_EXPR(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[:] * _10;
  UNSIGNED_16 _11;
  UNSIGNED_16 _12;
  sizetype _13;
  boolean _14;
  bool _21;
  boolean _22;
  unsigned short patt_23;
  boolean patt_24;

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

   [count: 4805]:

   [count: 4805]:
  goto ; [100.00%]

   [count: 0]:
  _14 = system__os_lib__normalize_pathname__is_with_drive (name);
  if (_14 != 0)
goto ; [50.00%]
  else
goto ; [50.00%]

   [count: 0]:
  goto ; [100.00%]

   [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 ; [50.00%]
  else
goto ; [50.00%]

   [count: 0]:
  goto ; [100.00%]

   [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(MEM[(character[D.8734:iftmp.827]
*)_10][_13 ...]{lb: _13 sz: 1});
  # DEBUG SR.150 => _8
  # DEBUG SR.151 => _9
  MEM  [(character[1:2] *)] = _8;
  MEM  [(character[1:2] *) + 1B] = _9;
  _12 = VIEW_CONVERT_EXPR(S343b.F);
  _21 = _11 != _12;
  _22 = (boolean) _21;

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

}

[Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada

2020-06-09 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582

--- Comment #4 from Martin Liška  ---
Created attachment 48711
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48711=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  for instructions.

@Richi: Can you please reproduce that?

[Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada

2020-06-09 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582

Martin Liška  changed:

   What|Removed |Added

   Keywords|needs-bisection |

--- Comment #3 from Martin Liška  ---
Started with r11-990-gf8ca4dd657f767c5f7da335462a5150ced368697 which added a
new vectorizer opportunity, it's not a culprit revision.

[Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada

2020-06-09 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582

Martin Liška  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  ---
I'm bisecting that right now..

[Bug bootstrap/95582] [11 Regression] LTO lean + PGO bootstrap is broken in Ada

2020-06-09 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95582

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|--- |11.0
   Priority|P3  |P1

--- Comment #1 from Richard Biener  ---
Hmm, let's see if we get a non FDO testcase for this ...