diff options
author | Roger Sayle <roger@eyesopen.com> | 2004-06-12 19:41:51 +0000 |
---|---|---|
committer | Roger Sayle <sayle@gcc.gnu.org> | 2004-06-12 19:41:51 +0000 |
commit | 08039bd80bfdee7e30ff80b0eb8873ea60ba2a50 (patch) | |
tree | 7e11e3760e9116204227c10877ce045689c9dece /gcc/fold-const.c | |
parent | a2a2059fd77eb8c30c0534cbc766c21072a9829a (diff) | |
download | gcc-08039bd80bfdee7e30ff80b0eb8873ea60ba2a50.zip gcc-08039bd80bfdee7e30ff80b0eb8873ea60ba2a50.tar.gz gcc-08039bd80bfdee7e30ff80b0eb8873ea60ba2a50.tar.bz2 |
fold-const.c (omit_two_operands): New function.
* fold-const.c (omit_two_operands): New function.
* tree.h (omit_two_operands): Prototype here.
* builtins.c (fold_builtin_unordered_cmp): New function to lower
C99 unordered comparison builtins to the appropriate tree nodes.
(fold_builtin_1): Use fold_builtin_unordered_cmp to lower
BUILT_IN_ISGREATER, BUILT_IN_ISGREATEREQUAL, BUILT_IN_ISLESS,
BUILT_IN_ISLESSEQUAL and BUILT_IN_ISLESSGREATER. Manually lower
BUILT_IN_ISUNORDERED comparisons to an UNORDERED_EXPR tree node.
(simplify_builtin_memcmp, simplify_builtin_strncmp,
simplify_builtin_strncat, simplify_builtin_strspn): Use the new
omit_two_operands function to build the required COMPOUND_EXPRs.
From-SVN: r83040
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 3a7053e..02f4128 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -2828,6 +2828,29 @@ pedantic_omit_one_operand (tree type, tree result, tree omitted) return pedantic_non_lvalue (t); } + +/* Return a tree for the case when the result of an expression is RESULT + converted to TYPE and OMITTED1 and OMITTED2 were previously operands + of the expression but are now not needed. + + If OMITTED1 or OMITTED2 has side effects, they must be evaluated. + If both OMITTED1 and OMITTED2 have side effects, OMITTED1 is + evaluated before OMITTED2. Otherwise, if neither has side effects, + just do the conversion of RESULT to TYPE. */ + +tree +omit_two_operands (tree type, tree result, tree omitted1, tree omitted2) +{ + tree t = fold_convert (type, result); + + if (TREE_SIDE_EFFECTS (omitted2)) + t = build2 (COMPOUND_EXPR, type, omitted2, t); + if (TREE_SIDE_EFFECTS (omitted1)) + t = build2 (COMPOUND_EXPR, type, omitted1, t); + + return TREE_CODE (t) != COMPOUND_EXPR ? non_lvalue (t) : t; +} + /* Return a simplified tree node for the truth-negation of ARG. This never alters ARG itself. We assume that ARG is an operation that |