Bug 43610 - [4.5 Regression] ICE: in prepare_float_lib_cmp, at optabs.c:4392 with -fno-trapping-math and _Decimal64 comparison
Summary: [4.5 Regression] ICE: in prepare_float_lib_cmp, at optabs.c:4392 with -fno-tr...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.5.0
: P2 normal
Target Milestone: 4.6.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2010-03-31 21:41 UTC by Zdenek Sojka
Modified: 2012-07-02 10:45 UTC (History)
4 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-04-01 13:48:17


Attachments
patch (1.03 KB, patch)
2010-04-01 16:10 UTC, Paolo Bonzini
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Sojka 2010-03-31 21:41:33 UTC
Command line:
gcc -fno-trapping-math testcase.c

------ testcase.c ------
int foo(_Decimal64 x[2])
{
  return !(x[0] < x[1]);
}
------------------------

Tested revisions:
r157877 - crash
r153685 - crash
4.4 r157895 - OK

Compiler output:
$ /mnt/svn/gcc-trunk/binary-157877-lto/bin/gcc -fno-trapping-math testcase.c
testcase.c: In function 'foo':
testcase.c:3:3: internal compiler error: in prepare_float_lib_cmp, at optabs.c:4392
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Richard Biener 2010-04-01 13:48:17 UTC
Because we only have an optab for LT (reversed UNGE), but
FLOAT_LIB_COMPARE_RETURNS_BOOL is false.

Without -fno-trapping-math we use LT from the start which works.

I suppose FLOAT_LIB_COMPARE_RETURNS_BOOL should return true for decimal
float modes on x86?
Comment 2 Richard Biener 2010-04-01 13:51:44 UTC
And I believe the regression is because of either cond-optab or expand-from-SSA
which causes us no longer to fallback to expand a UNORD b || a >= b.
Comment 3 H.J. Lu 2010-04-01 13:59:34 UTC
(In reply to comment #1)
> Because we only have an optab for LT (reversed UNGE), but
> FLOAT_LIB_COMPARE_RETURNS_BOOL is false.
> 
> Without -fno-trapping-math we use LT from the start which works.
> 
> I suppose FLOAT_LIB_COMPARE_RETURNS_BOOL should return true for decimal
> float modes on x86?
> 

I don't think so.
Comment 4 H.J. Lu 2010-04-01 15:37:32 UTC
It is caused by revision 149031:

http://gcc.gnu.org/ml/gcc-cvs/2009-06/msg01016.html
Comment 5 Paolo Bonzini 2010-04-01 16:10:28 UTC
Created attachment 20279 [details]
patch

Here is a totally untested patch...
Comment 6 Richard Biener 2010-04-03 17:16:21 UTC
Patch looks a bit big for 4.5.0.
Comment 7 Richard Biener 2010-04-06 11:20:58 UTC
GCC 4.5.0 is being released.  Deferring to 4.5.1.
Comment 8 Paolo Bonzini 2010-04-07 10:33:41 UTC
The patch is mostly splitting an if statement in two parts.  If anyone can test it for 4.5.1/4.6 that would be nice.
Comment 9 Zdenek Sojka 2010-04-09 17:21:27 UTC
Thank you for the patch. I tested it in trunk r158150 at x86_64-unix, it bootstrapped fine (languages=c,c++,lto,fortran).
check with RUNTESTFLAGS="--target_board=unix/-fno-trapping-math" fixed following FAILs (compared to clean r158150):

FAIL: c-c++-common/dfp/compare-rel-d128.c (internal compiler error)
FAIL: c-c++-common/dfp/compare-rel-d128.c (test for excess errors)
FAIL: c-c++-common/dfp/compare-rel-d32.c (internal compiler error)
FAIL: c-c++-common/dfp/compare-rel-d32.c (test for excess errors)
FAIL: c-c++-common/dfp/compare-rel-d64.c (internal compiler error)
FAIL: c-c++-common/dfp/compare-rel-d64.c (test for excess errors)
FAIL: c-c++-common/dfp/compare-rel-dfp.c (internal compiler error)
FAIL: c-c++-common/dfp/compare-rel-dfp.c (test for excess errors)
FAIL: c-c++-common/dfp/compare-special-d128.c (internal compiler error)
FAIL: c-c++-common/dfp/compare-special-d128.c (test for excess errors)
FAIL: c-c++-common/dfp/compare-special-d32.c (internal compiler error)
FAIL: c-c++-common/dfp/compare-special-d32.c (test for excess errors)
FAIL: c-c++-common/dfp/compare-special-d64.c (internal compiler error)
FAIL: c-c++-common/dfp/compare-special-d64.c (test for excess errors)
FAIL: c-c++-common/dfp/convert-dfp.c (internal compiler error)
FAIL: c-c++-common/dfp/convert-dfp.c (test for excess errors)
FAIL: c-c++-common/dfp/nan-2.c (internal compiler error)
FAIL: c-c++-common/dfp/nan-2.c (test for excess errors)

FAIL: c-c++-common/dfp/compare-rel-d128.c (internal compiler error)
FAIL: c-c++-common/dfp/compare-rel-d128.c (test for excess errors)
FAIL: c-c++-common/dfp/compare-rel-d32.c (internal compiler error)
FAIL: c-c++-common/dfp/compare-rel-d32.c (test for excess errors)
FAIL: c-c++-common/dfp/compare-rel-d64.c (internal compiler error)
FAIL: c-c++-common/dfp/compare-rel-d64.c (test for excess errors)
FAIL: c-c++-common/dfp/compare-rel-dfp.c (internal compiler error)
FAIL: c-c++-common/dfp/compare-rel-dfp.c (test for excess errors)
FAIL: c-c++-common/dfp/compare-special-d128.c (internal compiler error)
FAIL: c-c++-common/dfp/compare-special-d128.c (test for excess errors)
FAIL: c-c++-common/dfp/compare-special-d32.c (internal compiler error)
FAIL: c-c++-common/dfp/compare-special-d32.c (test for excess errors)
FAIL: c-c++-common/dfp/compare-special-d64.c (internal compiler error)
FAIL: c-c++-common/dfp/compare-special-d64.c (test for excess errors)
FAIL: c-c++-common/dfp/convert-dfp.c (internal compiler error)
FAIL: c-c++-common/dfp/convert-dfp.c (test for excess errors)
FAIL: c-c++-common/dfp/nan-2.c (internal compiler error)
FAIL: c-c++-common/dfp/nan-2.c (test for excess errors)

and didn't add any new FAIL

The testcase works fine too. I didn't verify if the generated code is correct.
Comment 10 Zdenek Sojka 2010-05-09 14:01:14 UTC
I hope my comment wasn't misunderstood - the patch from comment #5 fixes several FAILs and doesn't introduce any regressions (at least in r158150)
Comment 11 Paolo Bonzini 2010-05-09 14:14:13 UTC
Patch posted now.

Sorry, I was busy.
Comment 12 Paolo Bonzini 2010-05-25 09:19:57 UTC
Subject: Bug 43610

Author: bonzini
Date: Tue May 25 09:19:37 2010
New Revision: 159813

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159813
Log:
2010-05-09  Paolo Bonzini  <bonzini@gnu.org>

	PR target/43610
	* optabs.c (prepare_float_lib_cmp): Allow reversing the comparison
	even if !FLOAT_LIB_COMPARE_RETURNS_BOOL.  Always compute true_rtx and
	false_rtx.  Use false_rtx to compute the correct *ptest for reversed
	comparisons for which !FLOAT_LIB_COMPARE_RETURNS_BOOL.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/optabs.c

Comment 13 Jakub Jelinek 2010-06-29 16:30:30 UTC
Fixed on the trunk, unfixed on the branch.
Comment 14 Richard Biener 2010-07-31 09:29:43 UTC
GCC 4.5.1 is being released, adjusting target milestone.
Comment 15 Richard Biener 2010-12-16 13:03:07 UTC
GCC 4.5.2 is being released, adjusting target milestone.
Comment 16 Richard Biener 2011-04-28 14:51:21 UTC
GCC 4.5.3 is being released, adjusting target milestone.
Comment 17 Richard Biener 2012-07-02 10:45:12 UTC
Fixed in 4.6.0, the 4.5 branch is being closed.