This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [4.1/4.0/3.4] fix pr19672 by tuning expansion of TRUTH_{AND,OR}_EXPR


Eric Botcazou wrote:
> I'm comfortable with testing the side-effects bit.  I'm pretty sure there's
> lots of similar code elsewhere: for example, I distinctly remember writing
> some and I'm pretty sure much of it is still there.  If your testing shows
> that fixes the problem, I think it's OK to do it that way and not revert
> the change.

Well, Paolo has already reverted the change on the 3.4 branch. I'll conduct thorough testing on mainline but, frankly, I think we're better off not fiddling with the side-effects bit on 3.4 at this point.

On 4.0/4.1 an expression without TREE_SIDE_EFFECTS would have confused the tree-ssa optimizers beyond any recognition. Even though I'm surprised that such a TRUTH_AND_EXPR can be produced at all! BTW, is it triggered by some ACATS test, so I can look at a test case? I couldn't find any new ACATS failures on test-results.


I agree about 3.4, we'd better err on the safe side there.

Patch committed to 4.0/4.1.

Paolo

2005-10-21 Paolo Bonzini <bonzini@gnu.org>

        * dojump.c (do_jump): Handle side-effecting TRUTH_AND_EXPR and
        TRUTH_OR_EXPR.


Index: dojump.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/dojump.c,v retrieving revision 1.37.8.2 diff -p -u -r1.37.8.2 dojump.c --- dojump.c 19 Oct 2005 10:41:02 -0000 1.37.8.2 +++ dojump.c 21 Oct 2005 07:30:08 -0000 @@ -511,8 +511,10 @@ do_jump (tree exp, rtx if_false_label, r break;

     case TRUTH_AND_EXPR:
-      /* High branch cost, expand as the bitwise AND of the conditions.  */
-      if (BRANCH_COST >= 4)
+      /* High branch cost, expand as the bitwise AND of the conditions.
+        Do the same if the RHS has side effects, because we're effectively
+        turning a TRUTH_AND_EXPR into a TRUTH_ANDIF_EXPR.  */
+      if (BRANCH_COST >= 4 || TREE_SIDE_EFFECTS (TREE_OPERAND (exp, 1)))
        goto normal;

       if (if_false_label == NULL_RTX)
@@ -529,8 +531,10 @@ do_jump (tree exp, rtx if_false_label, r
       break;

     case TRUTH_OR_EXPR:
-      /* High branch cost, expand as the bitwise OR of the conditions.  */
-      if (BRANCH_COST >= 4)
+      /* High branch cost, expand as the bitwise OR of the conditions.
+        Do the same if the RHS has side effects, because we're effectively
+        turning a TRUTH_OR_EXPR into a TRUTH_ORIF_EXPR.  */
+      if (BRANCH_COST >= 4 || TREE_SIDE_EFFECTS (TREE_OPERAND (exp, 1)))
        goto normal;

if (if_true_label == NULL_RTX)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]