Message ID | alpine.LSU.2.11.1507280919060.19642@zhemvz.fhfr.qr |
---|---|
State | New |
Headers | show |
Hi, On 07/28/2015 09:20 AM, Richard Biener wrote: > This moves/merges the equality folding of decl addresses from > fold_comparison with that from fold_binary in match.pd. > > Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. > > Richard. > > 2015-07-28 Richard Biener <rguenther@suse.de> > > * fold-const.c (fold_comparison): Remove equality folding > of decl addresses ... > * match.pd: ... here and merge with existing pattern. I didn't double check with r226298, but I'm pretty sure this change of yours has to do with the FAIL: FAIL: experimental/optional/constexpr/make_optional.cc (test for excess errors) UNRESOLVED: experimental/optional/constexpr/make_optional.cc compilation failed to produce executable which now we are all seeing. Certainly the FAIL is there with r226299 and the library was clean a few revisions before. Note that the testcase involves comparisons of decl addresses ;) Thanks, Paolo.
On July 29, 2015 6:14:58 PM GMT+02:00, Paolo Carlini <paolo.carlini@oracle.com> wrote: >Hi, > >On 07/28/2015 09:20 AM, Richard Biener wrote: >> This moves/merges the equality folding of decl addresses from >> fold_comparison with that from fold_binary in match.pd. >> >> Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to >trunk. >> >> Richard. >> >> 2015-07-28 Richard Biener <rguenther@suse.de> >> >> * fold-const.c (fold_comparison): Remove equality folding >> of decl addresses ... >> * match.pd: ... here and merge with existing pattern. >I didn't double check with r226298, but I'm pretty sure this change of >yours has to do with the FAIL: > >FAIL: experimental/optional/constexpr/make_optional.cc (test for excess > >errors) >UNRESOLVED: experimental/optional/constexpr/make_optional.cc >compilation >failed to produce executable > >which now we are all seeing. Certainly the FAIL is there with r226299 >and the library was clean a few revisions before. Note that the >testcase >involves comparisons of decl addresses ;) Yeah, fix is in testing. Richard. >Thanks, >Paolo.
Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c (revision 226240) +++ gcc/fold-const.c (working copy) @@ -8511,30 +8389,6 @@ fold_comparison (location_t loc, enum tr return fold_build2_loc (loc, code, type, offset0, offset1); } } - /* For non-equal bases we can simplify if they are addresses - declarations with different addresses. */ - else if (indirect_base0 && indirect_base1 - /* We know that !operand_equal_p (base0, base1, 0) - because the if condition was false. But make - sure two decls are not the same. */ - && base0 != base1 - && TREE_CODE (arg0) == ADDR_EXPR - && TREE_CODE (arg1) == ADDR_EXPR - && DECL_P (base0) - && DECL_P (base1) - /* Watch for aliases. */ - && (!decl_in_symtab_p (base0) - || !decl_in_symtab_p (base1) - || !symtab_node::get_create (base0)->equal_address_to - (symtab_node::get_create (base1)))) - { - if (code == EQ_EXPR) - return omit_two_operands_loc (loc, type, boolean_false_node, - arg0, arg1); - else if (code == NE_EXPR) - return omit_two_operands_loc (loc, type, boolean_true_node, - arg0, arg1); - } /* For equal offsets we can simplify to a comparison of the base addresses. */ else if (bitpos0 == bitpos1 Index: gcc/match.pd =================================================================== --- gcc/match.pd (revision 226240) +++ gcc/match.pd (working copy) @@ -1808,15 +1869,20 @@ (define_operator_list CBRT BUILT_IN_CBRT have access to attributes for externs), then we know the result. */ (simplify (cmp (convert? addr@0) (convert? addr@1)) - (if (decl_in_symtab_p (TREE_OPERAND (@0, 0)) - && decl_in_symtab_p (TREE_OPERAND (@1, 0))) - (with - { - int equal = symtab_node::get_create (TREE_OPERAND (@0, 0)) + (if (DECL_P (TREE_OPERAND (@0, 0)) + && DECL_P (TREE_OPERAND (@1, 0))) + (if (decl_in_symtab_p (TREE_OPERAND (@0, 0)) + && decl_in_symtab_p (TREE_OPERAND (@1, 0))) + (with + { + int equal = symtab_node::get_create (TREE_OPERAND (@0, 0)) ->equal_address_to (symtab_node::get_create (TREE_OPERAND (@1, 0))); - } - (if (equal != 2) - { constant_boolean_node (equal ? cmp == EQ_EXPR : cmp != EQ_EXPR, type); })))) + } + (if (equal != 2) + { constant_boolean_node (equal + ? cmp == EQ_EXPR : cmp != EQ_EXPR, type); })) + (if (TREE_OPERAND (@0, 0) != TREE_OPERAND (@1, 0)) + { constant_boolean_node (cmp == EQ_EXPR ? false : true, type); })))) (simplify (cmp (convert? addr@0) integer_zerop)