On Thu, 6 Nov 2014, Marc Glisse wrote: > On Thu, 6 Nov 2014, Richard Biener wrote: > > > On Thu, 6 Nov 2014, Marc Glisse wrote: > > > > > On Thu, 6 Nov 2014, Richard Biener wrote: > > > > > > > +/* Try simple folding for X op !X, and X op X with the help > > > > + of the truth_valued_p and logical_inverted_value predicates. */ > > > > +(match truth_valued_p > > > > + @0 > > > > + (if (INTEGRAL_TYPE_P (type) && TYPE_PRECISION (type) == 1))) > > > > +(for op (lt le eq ne ge gt truth_and truth_andif truth_or truth_orif > > > > truth_xor) > > > > + (match truth_valued_p > > > > + (op @0 @1))) > > > > +(match truth_valued_p > > > > + (truth_not @0)) > > > > + > > > > +(match (logical_inverted_value @0) > > > > + (bit_not truth_valued_p@0)) > > > > +(match (logical_inverted_value @0) > > > > + (eq @0 integer_zerop) > > > > + (if (INTEGRAL_TYPE_P (TREE_TYPE (@0))))) > > > > +(match (logical_inverted_value @0) > > > > + (ne truth_valued_p@0 integer_onep) > > > > + (if (INTEGRAL_TYPE_P (TREE_TYPE (@0))))) > > > > +(match (logical_inverted_value @0) > > > > + (bit_xor truth_valued_p@0 integer_onep)) > > > > + > > > > +/* X & !X -> 0. */ > > > > +(simplify > > > > + (bit_and:c @0 (logical_inverted_value @0)) > > > > + { build_zero_cst (type); }) > > > > +/* X | !X and X ^ !X -> 1, , if X is truth-valued. */ > > > > +(for op (bit_ior bit_xor) > > > > + (simplify > > > > + (op:c truth_valued_p@0 (logical_inverted_value @0)) > > > > + { build_one_cst (type); })) > > > > > > Shouldn't that be build_true_cst (type) so it is -1 for vectors? It > > > seems that it could match: > > > vec a, b; > > > vec c=a<b; > > > vec d=~c; > > > vec e=c|d; > > > > Probably. Note that I copied this from tree-ssa-forwprop.c. > > > > Generally I try to avoid fixing bugs or improving things at this point > > to make the transition more obvious. > > But truth_valued_ssa_name starts with: > > if (!INTEGRAL_TYPE_P (type)) > return false; > > so it does not match vectors. lookup_logical_inverted_value has a similar > test.
But truth_valued_p doesn't catch vector types, no? That said, the > > > > +(match (logical_inverted_value @0) > > > > + (bit_xor truth_valued_p@0 integer_onep)) would have a similar issue for vectors? I'll happily approve a patch that makes it work correctly for vectors (with a testcase)! A bug with a testcase that is miscompiled is also ok, I'll fix that then. Thanks, Richard.