Bug 64213

Summary: gimple-match.c:1523:6: error: ‘GIMPLE’ was not declared in this scope
Product: gcc Reporter: Uroš Bizjak <ubizjak>
Component: bootstrapAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: hjl.tools, rguenth
Priority: P3    
Version: 5.0   
Target Milestone: 4.8.4   
Host: Target: alphaev68-linux-gnu
Build: Known to work:
Known to fail: Last reconfirmed: 2014-12-08 00:00:00

Description Uroš Bizjak 2014-12-07 18:37:35 UTC
/space/homedirs/uros/gcc-build/./prev-gcc/xg++ -B/space/homedirs/uros/gcc-build/./prev-gcc/ -B/usr/local/alphaev68-unknown-linux-gnu/bin/ -nostdinc++ -B/space/homedirs/uros/gcc-build/prev-alphaev68-unknown-linux-gnu/libstdc++-v3/src/.libs -B/space/homedirs/uros/gcc-build/prev-alphaev68-unknown-linux-gnu/libstdc++-v3/libsupc++/.libs  -I/space/homedirs/uros/gcc-build/prev-alphaev68-unknown-linux-gnu/libstdc++-v3/include/alphaev68-unknown-linux-gnu  -I/space/homedirs/uros/gcc-build/prev-alphaev68-unknown-linux-gnu/libstdc++-v3/include  -I/space/homedirs/uros/gcc-svn/trunk/libstdc++-v3/libsupc++ -L/space/homedirs/uros/gcc-build/prev-alphaev68-unknown-linux-gnu/libstdc++-v3/src/.libs -L/space/homedirs/uros/gcc-build/prev-alphaev68-unknown-linux-gnu/libstdc++-v3/libsupc++/.libs -c   -g -O2 -gtoggle -DIN_GCC    -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common -Wno-unused -DHAVE_CONFIG_H -I. -I. -I../../gcc-svn/trunk/gcc -I../../gcc-svn/trunk/gcc/. -I../../gcc-svn/trunk/gcc/../include -I../../gcc-svn/trunk/gcc/../libcpp/include  -I../../gcc-svn/trunk/gcc/../libdecnumber -I../../gcc-svn/trunk/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc-svn/trunk/gcc/../libbacktrace   -o gimple-match.o -MT gimple-match.o -MMD -MP -MF ./.deps/gimple-match.TPo gimple-match.c
gimple-match.c: In function ‘bool gimple_simplify(code_helper*, tree_node**, gimple_statement_base**, tree_node* (*)(tree), code_helper, tree, tree)’:
gimple-match.c:1523:6: error: ‘GIMPLE’ was not declared in this scope
 if ((GIMPLE && useless_type_conversion_p (type, TREE_TYPE (captures[0]))) || (0 && type == TREE_TYPE (captures[0])))
      ^
gimple-match.c:1573:7: error: ‘GIMPLE’ was not declared in this scope
 if (((GIMPLE && useless_type_conversion_p (type, inside_type)) || (0 && TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (inside_type))) && (((inter_int || inter_ptr) && final_int) || (inter_float && final_float)) && inter_prec >= final_prec)
       ^
gimple-match.c:1821:7: error: ‘GIMPLE’ was not declared in this scope
 if (((GIMPLE && useless_type_conversion_p (type, inside_type)) || (0 && TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (inside_type))) && (((inter_int || inter_ptr) && final_int) || (inter_float && final_float)) && inter_prec >= final_prec)
       ^
gimple-match.c:2086:6: error: ‘GIMPLE’ was not declared in this scope
 if ((GIMPLE && useless_type_conversion_p (type, TREE_TYPE (captures[0]))) || (0 && type == TREE_TYPE (captures[0])))
      ^
gimple-match.c:2190:6: error: ‘GIMPLE’ was not declared in this scope
 if ((GIMPLE && useless_type_conversion_p (type, TREE_TYPE (captures[0]))) || (0 && type == TREE_TYPE (captures[0])))
      ^
gimple-match.c:2240:7: error: ‘GIMPLE’ was not declared in this scope
 if (((GIMPLE && useless_type_conversion_p (type, inside_type)) || (0 && TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (inside_type))) && (((inter_int || inter_ptr) && final_int) || (inter_float && final_float)) && inter_prec >= final_prec)
       ^
gimple-match.c:2488:7: error: ‘GIMPLE’ was not declared in this scope
 if (((GIMPLE && useless_type_conversion_p (type, inside_type)) || (0 && TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (inside_type))) && (((inter_int || inter_ptr) && final_int) || (inter_float && final_float)) && inter_prec >= final_prec)
       ^
gimple-match.c:2718:6: error: ‘GIMPLE’ was not declared in this scope
 if ((GIMPLE && useless_type_conversion_p (type, TREE_TYPE (captures[0]))) || (0 && type == TREE_TYPE (captures[0])))
      ^
gimple-match.c:2768:7: error: ‘GIMPLE’ was not declared in this scope
 if (((GIMPLE && useless_type_conversion_p (type, inside_type)) || (0 && TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (inside_type))) && (((inter_int || inter_ptr) && final_int) || (inter_float && final_float)) && inter_prec >= final_prec)
       ^
gimple-match.c:3016:7: error: ‘GIMPLE’ was not declared in this scope
Comment 1 Uroš Bizjak 2014-12-07 18:40:15 UTC
It looks that GIMPLE is not substituted with "1", leaving following in generated gimple-match.c:

...
CASE_CONVERT:
{
{
/* #line 612 "../../gcc-svn/trunk/gcc/match.pd" */
tree captures[1] ATTRIBUTE_UNUSED = {};
captures[0] = op0;
/* #line 610 "../../gcc-svn/trunk/gcc/match.pd" */
if ((GIMPLE && useless_type_conversion_p (type, TREE_TYPE (captures[0]))) || (0 && type == TREE_TYPE (captures[0])))
{
if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Applying pattern match.pd:612, %s:%d\n", __FILE__, __LINE__);
res_ops[0] = captures[0];
*res_code = TREE_CODE (res_ops[0]);
return true;
...

Pleae note the above "if ((GIMPLE && ...)) condition.
Comment 2 Richard Biener 2014-12-08 13:30:42 UTC
Hmm, it definitely works on x86_64-linux.  It is supposed to work via doing

  cpp_define (r, gimple ? "GIMPLE=1": "GENERIC=1");
  cpp_define (r, gimple ? "GENERIC=0": "GIMPLE=0");

in genmatch.c which should cause 'GIMPLE' to lex as '1'.  And indeed on x86_64-linux I see in gimple-match.c:

/* #line 610 "/space/rguenther/src/svn/trunk/gcc/match.pd" */
if ((1 && useless_type_conversion_p (type, TREE_TYPE (captures[0]))) || (0 && type == TREE_TYPE (captures[0])))


which means libcpp is miscompiled...?  I notice that stage1 seems to work
for you?
Comment 3 Uroš Bizjak 2014-12-08 20:23:11 UTC
(In reply to Richard Biener from comment #2)

> which means libcpp is miscompiled...?  I notice that stage1 seems to work
> for you?

Yes, it is a miscompilation due to r218161.

Backing out r218161 with following patch allows bootstrap to proceed to stage3:

--cut here--
Index: combine.c
===================================================================
--- combine.c   (revision 218489)
+++ combine.c   (working copy)
@@ -1580,7 +1580,7 @@ setup_incoming_promotions (rtx_insn *first)
 
       /* The mode and signedness of the argument as it is actually passed,
          see assign_parm_setup_reg in function.c.  */
-      mode3 = promote_function_mode (TREE_TYPE (arg), mode1, &uns1,
+      mode3 = promote_function_mode (DECL_ARG_TYPE (arg), mode2, &uns3,
                                     TREE_TYPE (cfun->decl), 0);
 
       /* The mode of the register in which the argument is being passed.  */
--cut here--
Comment 4 Uroš Bizjak 2014-12-09 11:28:52 UTC
One of several testsuite failures (with non-bootstrapped compiler) is:

FAIL: gcc.c-torture/execute/20020805-1.c   -Os  execution test

--cut here--
extern void abort (void);
extern void exit (int);

void check (unsigned int m)
{
  if (m != (unsigned int) -1)
    abort ();
}

unsigned int n = 1;

int main (void)
{
  unsigned int m;
  m = (1 | (2 - n)) | (-n);
  check (m);
  exit (0);
}
--cut here--

So, the difference between trunk (+) and trunk with reverted patch (-) starts at _.214r.combine, where "check" function gets miscompiled:

     4: NOTE_INSN_BASIC_BLOCK 2
     2: NOTE_INSN_DELETED
     3: NOTE_INSN_FUNCTION_BEG
-    6: r71:DI=zero_extend($16:SI)
-      REG_DEAD $16:DI
+    6: NOTE_INSN_DELETED
     7: r73:DI=0xffffffffffffffff
     8: r72:DI=r73:DI 0>>0x20
       REG_DEAD r73:DI
       REG_EQUAL 0xffffffff
-    9: r74:DI=r71:DI==r72:DI
+    9: r74:DI=$16:DI==r72:DI
+      REG_DEAD $16:DI
       REG_DEAD r72:DI
-      REG_DEAD r71:DI
    10: pc={(r74:DI!=0)?L16:pc}
       REG_DEAD r74:DI
       REG_BR_PROB 9996

This results in an asm code difference, where needed SI->DI zero_extend is missing:

@@ -18,7 +18,6 @@
        lda $1,-1($31)
        lda $30,-16($30)
        .cfi_def_cfa_offset 16
-       zapnot $16,15,$16
        srl $1,32,$1
        stq $26,0($30)
        .cfi_offset 26, -16

I propose to revert H.J.'s patch for PR64037.
Comment 5 rguenther@suse.de 2014-12-09 11:41:29 UTC
On Tue, 9 Dec 2014, ubizjak at gmail dot com wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64213
> 
> --- Comment #4 from Uroš Bizjak <ubizjak at gmail dot com> ---
> One of several testsuite failures (with non-bootstrapped compiler) is:
> 
> FAIL: gcc.c-torture/execute/20020805-1.c   -Os  execution test
> 
> --cut here--
> extern void abort (void);
> extern void exit (int);
> 
> void check (unsigned int m)
> {
>   if (m != (unsigned int) -1)
>     abort ();
> }
> 
> unsigned int n = 1;
> 
> int main (void)
> {
>   unsigned int m;
>   m = (1 | (2 - n)) | (-n);
>   check (m);
>   exit (0);
> }
> --cut here--
> 
> So, the difference between trunk (+) and trunk with reverted patch (-) starts
> at _.214r.combine, where "check" function gets miscompiled:
> 
>      4: NOTE_INSN_BASIC_BLOCK 2
>      2: NOTE_INSN_DELETED
>      3: NOTE_INSN_FUNCTION_BEG
> -    6: r71:DI=zero_extend($16:SI)
> -      REG_DEAD $16:DI
> +    6: NOTE_INSN_DELETED
>      7: r73:DI=0xffffffffffffffff
>      8: r72:DI=r73:DI 0>>0x20
>        REG_DEAD r73:DI
>        REG_EQUAL 0xffffffff
> -    9: r74:DI=r71:DI==r72:DI
> +    9: r74:DI=$16:DI==r72:DI
> +      REG_DEAD $16:DI
>        REG_DEAD r72:DI
> -      REG_DEAD r71:DI
>     10: pc={(r74:DI!=0)?L16:pc}
>        REG_DEAD r74:DI
>        REG_BR_PROB 9996
> 
> This results in an asm code difference, where needed SI->DI zero_extend is
> missing:
> 
> @@ -18,7 +18,6 @@
>         lda $1,-1($31)
>         lda $30,-16($30)
>         .cfi_def_cfa_offset 16
> -       zapnot $16,15,$16
>         srl $1,32,$1
>         stq $26,0($30)
>         .cfi_offset 26, -16
> 
> I propose to revert H.J.'s patch for PR64037.

Agreed and approved.  Please make sure to re-open bugs that were
fixed by the patch.
Comment 6 uros 2014-12-09 14:35:04 UTC
Author: uros
Date: Tue Dec  9 14:34:32 2014
New Revision: 218516

URL: https://gcc.gnu.org/viewcvs?rev=218516&root=gcc&view=rev
Log:
	PR bootstrap/64213
	Revert:
	2014-11-28  H.J. Lu  <hongjiu.lu@intel.com>

	PR rtl-optimization/64037
	* combine.c (setup_incoming_promotions): Pass the argument
	before any promotions happen to promote_function_mode.

testsuite/ChangeLog:

	PR bootstrap/64213
	Revert:
	2014-11-28  H.J. Lu  <hongjiu.lu@intel.com>

	PR rtl-optimization/64037
	* g++.dg/pr64037.C: New test.


Removed:
    trunk/gcc/testsuite/g++.dg/pr64037.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/combine.c
    trunk/gcc/testsuite/ChangeLog
Comment 7 uros 2014-12-09 14:41:11 UTC
Author: uros
Date: Tue Dec  9 14:40:40 2014
New Revision: 218517

URL: https://gcc.gnu.org/viewcvs?rev=218517&root=gcc&view=rev
Log:
	PR bootstrap/64213
	Revert:
	2014-11-28  H.J. Lu  <hongjiu.lu@intel.com>

	PR rtl-optimization/64037
	* combine.c (setup_incoming_promotions): Pass the argument
	before any promotions happen to promote_function_mode.

testsuite/ChangeLog:

	PR bootstrap/64213
	Revert:
	2014-11-28  H.J. Lu  <hongjiu.lu@intel.com>

	PR rtl-optimization/64037
	* g++.dg/pr64037.C: New test.


Removed:
    branches/gcc-4_9-branch/gcc/testsuite/g++.dg/pr64037.C
Modified:
    branches/gcc-4_9-branch/gcc/ChangeLog
    branches/gcc-4_9-branch/gcc/combine.c
    branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
Comment 8 uros 2014-12-09 14:44:38 UTC
Author: uros
Date: Tue Dec  9 14:44:06 2014
New Revision: 218518

URL: https://gcc.gnu.org/viewcvs?rev=218518&root=gcc&view=rev
Log:
	PR bootstrap/64213
	Revert:
	2014-11-28  H.J. Lu  <hongjiu.lu@intel.com>

	PR rtl-optimization/64037
	* combine.c (setup_incoming_promotions): Pass the argument
	before any promotions happen to promote_function_mode.

testsuite/ChangeLog:

	PR bootstrap/64213
	Revert:
	2014-11-28  H.J. Lu  <hongjiu.lu@intel.com>

	PR rtl-optimization/64037
	* g++.dg/pr64037.C: New test.


Removed:
    branches/gcc-4_8-branch/gcc/testsuite/g++.dg/pr64037.C
Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/combine.c
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
Comment 9 Uroš Bizjak 2014-12-09 14:49:57 UTC
Fixed by reverting PR64037 patch everywhere.