diff options
author | Tom Wood <wood@gnu.org> | 1992-10-15 11:39:38 +0000 |
---|---|---|
committer | Tom Wood <wood@gnu.org> | 1992-10-15 11:39:38 +0000 |
commit | 8227896cf6130902ab124b04aceeae588545a5ae (patch) | |
tree | add1f5d6b65775c123656ad4445570d2393fd237 /gcc | |
parent | d15d0264a9edd630fc9500f027864309d9c2141e (diff) | |
download | gcc-8227896cf6130902ab124b04aceeae588545a5ae.zip gcc-8227896cf6130902ab124b04aceeae588545a5ae.tar.gz gcc-8227896cf6130902ab124b04aceeae588545a5ae.tar.bz2 |
(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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fold-const.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 351e13f..35bd938 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 |