From: Tom Wood Date: Thu, 15 Oct 1992 11:39:38 +0000 (+0000) Subject: (simple_operand_p): Don't regard global or static variables as simple. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8227896cf6130902ab124b04aceeae588545a5ae;p=gcc.git (simple_operand_p): Don't regard global or static variables as simple. (simple_operand_p): Don't regard global or static variables as simple. (fold_truthop): Only require the RHS to be simple. From-SVN: r2473 --- diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 351e13fa702..35bd9389432 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -2424,7 +2424,15 @@ simple_operand_p (exp) || (TREE_CODE_CLASS (TREE_CODE (exp)) == 'd' && ! TREE_ADDRESSABLE (exp) && ! TREE_THIS_VOLATILE (exp) - && ! DECL_NONLOCAL (exp))); + && ! DECL_NONLOCAL (exp) + /* Don't regard global variables as simple. They may be + allocated in ways unknown to the compiler (shared memory, + #pragma weak, etc). */ + && ! TREE_PUBLIC (exp) + && ! DECL_EXTERNAL (exp) + /* Loading a static variable is unduly expensive, but global + registers aren't expensive. */ + && (! TREE_STATIC (exp) || DECL_REGISTER (exp)))); } /* Subroutine for fold_truthop: try to optimize a range test. @@ -2657,7 +2665,7 @@ fold_truthop (code, truth_type, lhs, rhs) return result; } - /* If the RHS can be evaluated unconditionally and all operands are + /* If the RHS can be evaluated unconditionally and its operands are simple, it wins to evaluate the RHS unconditionally on machines with expensive branches. In this case, this isn't a comparison that can be merged. */ @@ -2668,9 +2676,7 @@ fold_truthop (code, truth_type, lhs, rhs) if (BRANCH_COST >= 2 && TREE_CODE (TREE_TYPE (rhs)) == INTEGER_TYPE && simple_operand_p (rl_arg) - && simple_operand_p (ll_arg) - && simple_operand_p (rr_arg) - && simple_operand_p (lr_arg)) + && simple_operand_p (rr_arg)) return build (code, truth_type, lhs, rhs); /* See if the comparisons can be merged. Then get all the parameters for