Commit 63cb92c1 by Jakub Jelinek Committed by Jakub Jelinek

re PR rtl-optimization/36017 (Miscompilation of tail call sqrt)

	PR rtl-optimization/36017
	* builtins.c (expand_errno_check): Clear CALL_EXPR_TAILCALL before
	expanding the library call.

	* gcc.dg/pr36017.c: New test.

From-SVN: r134569
parent d7b5fa31
2008-04-23 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/36017
* builtins.c (expand_errno_check): Clear CALL_EXPR_TAILCALL before
expanding the library call.
2008-04-22 Ian Lance Taylor <iant@google.com> 2008-04-22 Ian Lance Taylor <iant@google.com>
* fold-const.c (pointer_may_wrap_p): Call int_size_in_bytes rather * fold-const.c (pointer_may_wrap_p): Call int_size_in_bytes rather
......
...@@ -1804,6 +1804,9 @@ expand_errno_check (tree exp, rtx target) ...@@ -1804,6 +1804,9 @@ expand_errno_check (tree exp, rtx target)
} }
#endif #endif
/* Make sure the library call isn't expanded as a tail call. */
CALL_EXPR_TAILCALL (exp) = 0;
/* We can't set errno=EDOM directly; let the library call do it. /* We can't set errno=EDOM directly; let the library call do it.
Pop the arguments right away in case the call gets deleted. */ Pop the arguments right away in case the call gets deleted. */
NO_DEFER_POP; NO_DEFER_POP;
......
2008-04-23 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/36017
* gcc.dg/pr36017.c: New test.
2008-04-22 Jakub Jelinek <jakub@redhat.com> 2008-04-22 Jakub Jelinek <jakub@redhat.com>
PR c++/35747 PR c++/35747
/* PR rtl-optimization/36017 */
/* { dg-do run { target i?86-*-linux* x86_64-*-linux* } } */
/* { dg-options "-O2 -lm" } */
extern double sqrt (double);
extern void abort (void);
__attribute__((noinline)) double
foo (double a)
{
double b, c, d = 0.7;
if (a <= d)
b = sqrt (d * a);
else
{
c = (1.0 - d) * (1.0 - a);
b = c > 0 ? 1.0 - sqrt (c) : 1.0;
}
return b;
}
int
main (void)
{
double c = foo (0.5);
if (c > 0.5917)
abort ();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment