backport: re PR target/43305 (ICE: in emit_unop_insn, at optabs.c:3838 with -Os -ffast-math and ilogbl())

Backport from mainline:
	2010-03-19  Michael Matz  <matz@suse.de>

	PR target/43305
	* builtins.c (expand_builtin_interclass_mathfn,
	expand_builtin_signbit): Use maybe_emit_unop_insn, emit libcalls
	if that fails.

	* gcc.dg/pr43305.c: New testcase.

From-SVN: r157632
This commit is contained in:
Jakub Jelinek 2010-03-22 16:00:20 +01:00 committed by Jakub Jelinek
parent e327219929
commit af609ea4b7
4 changed files with 38 additions and 4 deletions

View File

@ -1,6 +1,13 @@
2010-03-22 Jakub Jelinek <jakub@redhat.com>
Backport from mainline:
2010-03-19 Michael Matz <matz@suse.de>
PR target/43305
* builtins.c (expand_builtin_interclass_mathfn,
expand_builtin_signbit): Use maybe_emit_unop_insn, emit libcalls
if that fails.
2010-03-18 Michael Matz <matz@suse.de>
PR middle-end/43419

View File

@ -2275,6 +2275,8 @@ expand_builtin_interclass_mathfn (tree exp, rtx target, rtx subtarget)
/* Before working hard, check whether the instruction is available. */
if (icode != CODE_FOR_nothing)
{
rtx last = get_last_insn ();
tree orig_arg = arg;
/* Make a suitable register to place result in. */
if (!target
|| GET_MODE (target) != TYPE_MODE (TREE_TYPE (exp)))
@ -2295,8 +2297,10 @@ expand_builtin_interclass_mathfn (tree exp, rtx target, rtx subtarget)
/* Compute into TARGET.
Set TARGET to wherever the result comes back. */
emit_unop_insn (icode, target, op0, UNKNOWN);
return target;
if (maybe_emit_unop_insn (icode, target, op0, UNKNOWN))
return target;
delete_insns_since (last);
CALL_EXPR_ARG (exp, 0) = orig_arg;
}
/* If there is no optab, try generic code. */
@ -5837,9 +5841,11 @@ expand_builtin_signbit (tree exp, rtx target)
icode = signbit_optab->handlers [(int) fmode].insn_code;
if (icode != CODE_FOR_nothing)
{
rtx last = get_last_insn ();
target = gen_reg_rtx (TYPE_MODE (TREE_TYPE (exp)));
emit_unop_insn (icode, target, temp, UNKNOWN);
return target;
if (maybe_emit_unop_insn (icode, target, temp, UNKNOWN))
return target;
delete_insns_since (last);
}
/* For floating point formats without a sign bit, implement signbit

View File

@ -1,6 +1,11 @@
2010-03-22 Jakub Jelinek <jakub@redhat.com>
Backport from mainline:
2010-03-19 Michael Matz <matz@suse.de>
PR target/43305
* gcc.dg/pr43305.c: New testcase.
2010-03-18 Michael Matz <matz@suse.de>
PR middle-end/43419

View File

@ -0,0 +1,16 @@
/* { dg-do compile } */
/* { dg-options "-Os -ffast-math" } */
extern int ilogbl(long double);
extern int printf(const char *format, ...);
__attribute__((noinline))
int foo(long double x)
{
return ilogbl(x);
}
int main()
{
printf("%d\n", foo(100));
return 0;
}