On Thu, Feb 02, 2017 at 10:12:32AM -0700, Jeff Law wrote: > On 02/01/2017 03:45 AM, Richard Biener wrote: > > > > I agree. But this means we should look for a vectorizer-local fix > > without a new global predicate then (there seem to be subtly different > > needs and coming up with good names for all of them sounds difficult...). > Well, we could go with Jakub's INTEGRAL_BOOLEAN_TYPE as posted, but in > contexts where we use it and really depend on single bit objects, we add the > precision == 1 check back. Jakub's patch removes the type precision check > in tree-vect-patterns for example. There's likely all kinds of places where > we need to add that check as well.
The 3 cases in tree-vect-patterns.c where I've removed the check were exactly what the proposed macro does, i.e. if ((TYPE_PRECISION (TREE_TYPE (rhs1)) != 1 || !TYPE_UNSIGNED (TREE_TYPE (rhs1))) && TREE_CODE (TREE_TYPE (rhs1)) != BOOLEAN_TYPE) return false; i.e. bail out unless the rhs1 type is a BOOLEAN_TYPE (any precision, assuming it has only valid values of 0 and 1) or unless it is unsigned precision type 1 integer (i.e. something that (if it has also QImode) forwprop etc. could have changed a BOOLEAN_TYPE with precision 1 into. Note Fortran has been using I think precision one boolean_type_node even in GCC 6.x, it had: boolean_type_node = gfc_get_logical_type (gfc_default_logical_kind); boolean_true_node = build_int_cst (boolean_type_node, 1); boolean_false_node = build_int_cst (boolean_type_node, 0); Fortran logical(4) etc. are built using: new_type = make_unsigned_type (bit_size); TREE_SET_CODE (new_type, BOOLEAN_TYPE); TYPE_MAX_VALUE (new_type) = build_int_cst (new_type, 1); TYPE_PRECISION (new_type) = 1; thus I believe they have e.g. SImode or DImode rather than QImode, but still TYPE_PRECISION of 1. The non-Ada boolean is also: boolean_type_node = make_unsigned_type (BOOL_TYPE_SIZE); TREE_SET_CODE (boolean_type_node, BOOLEAN_TYPE); TYPE_PRECISION (boolean_type_node) = 1; where BOOL_TYPE_SIZE is CHAR_TYPE_SIZE everywhere but on powerpc*-darwin* with some command line option. Ada is boolean_type_node = make_unsigned_type (8); TREE_SET_CODE (boolean_type_node, BOOLEAN_TYPE); and thus it is indeed precision 8 QImode. So, requiring precision 1 for all BOOLEAN_TYPEs in the vectorizer would only affect Ada. Requiring QImode or whatever other fixed TYPE_MODE in the macro for precision 1 unsigned non-BOOLEAN_TYPE integers would actually also affect Fortran a lot, because e.g. SImode precision 1 INTEGER_TYPE is considered compatible with SImode precision 1 BOOLEAN_TYPE. > /me is frustrated that we have booleans with nonstandard precision, even > though I understand why it was done. It creates numerous headaches. Ditto. Jakub