From 2c26730b9caf78019c2b713d82d895cb7fec3963 Mon Sep 17 00:00:00 2001 From: ghazi Date: Tue, 14 Nov 2006 05:08:46 +0000 Subject: * fold-const.c (fold_strip_sign_ops): Handle COMPOUND_EXPR and COND_EXPR. testsuite: * gcc.dg/builtins-20.c: Add more cases. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@118802 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fold-const.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'gcc/fold-const.c') diff --git a/gcc/fold-const.c b/gcc/fold-const.c index fe7ec587204..eb3b45701a4 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -13368,6 +13368,22 @@ fold_strip_sign_ops (tree exp) arg1 ? arg1 : TREE_OPERAND (exp, 1)); break; + case COMPOUND_EXPR: + arg0 = TREE_OPERAND (exp, 0); + arg1 = fold_strip_sign_ops (TREE_OPERAND (exp, 1)); + if (arg1) + return fold_build2 (COMPOUND_EXPR, TREE_TYPE (exp), arg0, arg1); + break; + + case COND_EXPR: + arg0 = fold_strip_sign_ops (TREE_OPERAND (exp, 1)); + arg1 = fold_strip_sign_ops (TREE_OPERAND (exp, 2)); + if (arg0 || arg1) + return fold_build3 (COND_EXPR, TREE_TYPE (exp), TREE_OPERAND (exp, 0), + arg0 ? arg0 : TREE_OPERAND (exp, 1), + arg1 ? arg1 : TREE_OPERAND (exp, 2)); + break; + case CALL_EXPR: /* Strip sign ops from the argument of "odd" math functions. */ if (negate_mathfn_p (builtin_mathfn_code (exp))) -- cgit v1.2.1