Bug 49123 - [4.6 Regression] FAIL: gcc.c-torture/execute/pr48973-[12].c
[4.6 Regression] FAIL: gcc.c-torture/execute/pr48973-[12].c
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: lto
4.6.1
: P3 normal
: 4.6.1
Assigned To: Jakub Jelinek
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-05-23 12:56 UTC by H.J. Lu
Modified: 2011-05-23 20:39 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-05-23 13:17:55


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2011-05-23 12:56:54 UTC
On Linux/x86, revision 174063 gave:

FAIL: gcc.c-torture/execute/pr48973-1.c execution,  -O2 -flto
FAIL: gcc.c-torture/execute/pr48973-1.c execution,  -O2 -flto
FAIL: gcc.c-torture/execute/pr48973-1.c execution,  -O2 -flto -flto-partition=none
FAIL: gcc.c-torture/execute/pr48973-1.c execution,  -O2 -flto -flto-partition=none
FAIL: gcc.c-torture/execute/pr48973-2.c execution,  -O2 -flto
FAIL: gcc.c-torture/execute/pr48973-2.c execution,  -O2 -flto
FAIL: gcc.c-torture/execute/pr48973-2.c execution,  -O2 -flto -flto-partition=none
FAIL: gcc.c-torture/execute/pr48973-2.c execution,  -O2 -flto -flto-partition=none

revision 174054 is OK.
Comment 1 Richard Biener 2011-05-23 13:14:58 UTC
Also aborts w/o LTO but with -fwhole-program.
Comment 2 Richard Biener 2011-05-23 13:17:55 UTC
Confirmed.  FRE does

 <bb 2>:
   s.f = 1;
-  D.2698_4 = s.f;
-  D.2699_5 = (unsigned int) D.2698_4;
-  if (D.2699_5 != 4294967295)
-    goto <bb 3>;
-  else
-    goto <bb 4>;
-
-<bb 3>:
+  D.2698_4 = 1;
+  D.2699_5 = 1;

so it fails to properly sign-extend D.2698_4.
Comment 3 Richard Biener 2011-05-23 13:22:12 UTC
The 1 is non-canonical:

(gdb) call debug_tree ($1)
 <integer_cst 0x7ffff5b25eb0 type <integer_type 0x7ffff5b29540> constant 1>
(gdb) call debug_tree (0x7ffff5b29540)
 <integer_type 0x7ffff5b29540 public QI
    size <integer_cst 0x7ffff7e734d8 type <integer_type 0x7ffff7e860a8 bit_size_type> constant 8>
    unit size <integer_cst 0x7ffff7e73500 type <integer_type 0x7ffff7e86000 long unsigned int> constant 1>
    align 8 symtab 0 alias set -1 canonical type 0x7ffff5b29540 precision 1 min <integer_cst 0x7ffff5b25690 -1> max <integer_cst 0x7ffff5b256b8 0>>
(gdb) p $1->int_cst.
common   int_cst  
(gdb) p $1->int_cst.int_cst 
$2 = {low = 1, high = 0}

built via build_int_cst, fixed on trunk by properly making that produce
canonical constants.
Comment 4 Richard Biener 2011-05-23 13:25:03 UTC
A less intrusive variant of the patch might be suitable for backporting
(it doesn't touch the NULL type argument path) and fixes the testcase for me.

Index: gcc/tree.c
===================================================================
--- gcc/tree.c  (revision 174066)
+++ gcc/tree.c  (working copy)
@@ -1034,9 +1034,9 @@ build_int_cst (tree type, HOST_WIDE_INT
 {
   /* Support legacy code.  */
   if (!type)
-    type = integer_type_node;
+    return build_int_cst_wide (integer_type_node, low, low < 0 ? -1 : 0);
 
-  return build_int_cst_wide (type, low, low < 0 ? -1 : 0);
+  return double_int_to_tree (type, shwi_to_double_int (low));
 }
 
 /* Create an INT_CST node with a LOW value in TYPE.  The value is sign extended
Comment 5 Jakub Jelinek 2011-05-23 13:30:21 UTC
Wonder if I'm not seeing it because my ld doesn't support plugins...
Comment 6 Jakub Jelinek 2011-05-23 13:36:00 UTC
(In reply to comment #4)
> A less intrusive variant of the patch might be suitable for backporting
> (it doesn't touch the NULL type argument path) and fixes the testcase for me.
> 
> Index: gcc/tree.c
> ===================================================================
> --- gcc/tree.c  (revision 174066)
> +++ gcc/tree.c  (working copy)
> @@ -1034,9 +1034,9 @@ build_int_cst (tree type, HOST_WIDE_INT
>  {
>    /* Support legacy code.  */
>    if (!type)
> -    type = integer_type_node;
> +    return build_int_cst_wide (integer_type_node, low, low < 0 ? -1 : 0);
> 
> -  return build_int_cst_wide (type, low, low < 0 ? -1 : 0);
> +  return double_int_to_tree (type, shwi_to_double_int (low));
>  }
> 
>  /* Create an INT_CST node with a LOW value in TYPE.  The value is sign
> extended

Alternatively you could call build_int_cst_type instead of build_int_cst in the spot where FRE? calls it.  Guess that would be even safer to backport.
Comment 7 Richard Biener 2011-05-23 13:56:49 UTC
That would be

Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c    (revision 174066)
+++ gcc/fold-const.c    (working copy)
@@ -5954,7 +5954,7 @@ constant_boolean_node (int value, tree t
   else if (type == boolean_type_node)
     return value ? boolean_true_node : boolean_false_node;
   else
-    return build_int_cst (type, value);
+    return build_int_cst_type (type, value);
 }
 
 
which works for me as well.
Comment 8 H.J. Lu 2011-05-23 14:36:44 UTC
(In reply to comment #5)
> Wonder if I'm not seeing it because my ld doesn't support plugins...

That is true.
Comment 9 Jakub Jelinek 2011-05-23 20:37:22 UTC
Author: jakub
Date: Mon May 23 20:37:18 2011
New Revision: 174087

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174087
Log:
	PR lto/49123
	* fold-const.c (constant_boolean_node): If type is non-NULL,
	use build_int_cst_type instead of build_int_cst.

	* gcc.c-torture/execute/pr49123.c: New test.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/gcc.c-torture/execute/pr49123.c
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/fold-const.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Comment 10 Jakub Jelinek 2011-05-23 20:38:19 UTC
Author: jakub
Date: Mon May 23 20:38:17 2011
New Revision: 174088

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174088
Log:
	PR lto/49123
	* gcc.c-torture/execute/pr49123.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr49123.c
Modified:
    trunk/gcc/testsuite/ChangeLog
Comment 11 Jakub Jelinek 2011-05-23 20:39:27 UTC
Fixed.