From 57bf1c0883636dc64bf5a4ded29269faacd8a2e5 Mon Sep 17 00:00:00 2001 From: bonzini Date: Fri, 21 Oct 2005 07:28:48 +0000 Subject: [PATCH] 2005-10-21 Paolo Bonzini * dojump.c (do_jump): Handle side-effecting TRUTH_AND_EXPR and TRUTH_OR_EXPR. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@105723 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 5 +++++ gcc/dojump.c | 12 ++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ddb82538509..06f3913da62 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2005-10-21 Paolo Bonzini + + * dojump.c (do_jump): Handle side-effecting TRUTH_AND_EXPR and + TRUTH_OR_EXPR. + 2005-10-20 Steven Bosscher PR tree-optimization/24225 diff --git a/gcc/dojump.c b/gcc/dojump.c index 6dca9d32b57..d65347ec67c 100644 --- a/gcc/dojump.c +++ b/gcc/dojump.c @@ -511,8 +511,10 @@ do_jump (tree exp, rtx if_false_label, rtx if_true_label) 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, rtx if_true_label) 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) -- 2.11.0