From 968fc3b64fd72e5ebab888ca442a007efc1dc1b4 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Wed, 22 Aug 2007 11:43:32 +0000 Subject: [PATCH] re PR middle-end/33007 (builtin lround doesn't work) 2007-08-22 Richard Guenther PR middle-end/33007 * builtins.c (expand_builtin_int_roundingfn): Replace call argument wrapped with SAVE_EXPR directly. (expand_builtin_int_roundingfn_2): Likewise. * gcc.dg/pr33007.c: New testcase. From-SVN: r127701 --- gcc/ChangeLog | 7 +++++++ gcc/builtins.c | 18 ++++-------------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr33007.c | 10 ++++++++++ 4 files changed, 26 insertions(+), 14 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr33007.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fd5015242c6..1280151524f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2007-08-22 Richard Guenther + + PR middle-end/33007 + * builtins.c (expand_builtin_int_roundingfn): Replace call + argument wrapped with SAVE_EXPR directly. + (expand_builtin_int_roundingfn_2): Likewise. + 2007-08-22 Richard Guenther * tree-inline.c (inlinable_function_p): Restore disregarding diff --git a/gcc/builtins.c b/gcc/builtins.c index cbe00c7dd3b..64f8185b723 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -2516,7 +2516,7 @@ expand_builtin_int_roundingfn (tree exp, rtx target, rtx subtarget) enum built_in_function fallback_fn; tree fallback_fndecl; enum machine_mode mode; - tree arg, narg; + tree arg; if (!validate_arglist (exp, REAL_TYPE, VOID_TYPE)) gcc_unreachable (); @@ -2549,12 +2549,7 @@ expand_builtin_int_roundingfn (tree exp, rtx target, rtx subtarget) /* Wrap the computation of the argument in a SAVE_EXPR, as we may need to expand the argument again. This way, we will not perform side-effects more the once. */ - narg = builtin_save_expr (arg); - if (narg != arg) - { - arg = narg; - exp = build_call_expr (fndecl, 1, arg); - } + CALL_EXPR_ARG (exp, 0) = builtin_save_expr (arg); op0 = expand_expr (arg, subtarget, VOIDmode, EXPAND_NORMAL); @@ -2646,7 +2641,7 @@ expand_builtin_int_roundingfn_2 (tree exp, rtx target, rtx subtarget) convert_optab builtin_optab; rtx op0, insns; tree fndecl = get_callee_fndecl (exp); - tree arg, narg; + tree arg; enum machine_mode mode; /* There's no easy way to detect the case we need to set EDOM. */ @@ -2678,12 +2673,7 @@ expand_builtin_int_roundingfn_2 (tree exp, rtx target, rtx subtarget) /* Wrap the computation of the argument in a SAVE_EXPR, as we may need to expand the argument again. This way, we will not perform side-effects more the once. */ - narg = builtin_save_expr (arg); - if (narg != arg) - { - arg = narg; - exp = build_call_expr (fndecl, 1, arg); - } + CALL_EXPR_ARG (exp, 0) = builtin_save_expr (arg); op0 = expand_expr (arg, subtarget, VOIDmode, EXPAND_NORMAL); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c77dec9e3f9..189097d0a58 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-08-22 Richard Guenther + + PR middle-end/33007 + * gcc.dg/pr33007.c: New testcase. + 2007-08-22 Richard Sandiford * gcc.c-torture/execute/strcmp-1.x: Delete. diff --git a/gcc/testsuite/gcc.dg/pr33007.c b/gcc/testsuite/gcc.dg/pr33007.c new file mode 100644 index 00000000000..b1fc4289be5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr33007.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ffast-math -ftrapping-math" } */ + +long +foo (int i) +{ + float x; + x = i; + return __builtin_lroundf (x); +}