Building glibc CVS, I get: ../sysdeps/posix/readv.c: In function `__atomic_readv_replacement': ../sysdeps/posix/readv.c:35: error: Invalid operand to binary operator (long int<D3>)T.182<D6760>_122; ../sysdeps/posix/readv.c:35: internal compiler error: verify_stmts failed. Please submit a full bug report, with preprocessed source if appropriate. Complete invocation is: $ /opt/gcc/tree-ssa-20020619-branch/bin/gcc ../sysdeps/ unix/sysv/linux/readv.c -c -std=gnu99 -O2 -Wall -Winline -Wstrict-prototypes -Wwrite-strings -g -fexceptions -fasynchronous-unwind-tables -I../include -I. -I/builds/glibc/tree-ssa/misc -I.. -I../libio -I/builds/glibc/tree-ssa -I../sysdeps/x86_64/elf -I../linuxthreads/sysdeps/unix/sysv/linux/x86_64 -I../linuxthreads/sysdeps/unix/sysv/linux -I../linuxthreads/sysdeps/pthread -I../sysdeps/pthread -I../linuxthreads/sysdeps/unix/sysv -I../linuxthreads/sysdeps/unix -I../linuxthreads/sysdeps/x86_64 -I../libidn/sysdeps/unix -I../sysdeps/unix/sysv/linux/x86_64 -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/common -I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../sysdeps/unix/sysv -I../sysdeps/unix/x86_64 -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/x86_64/fpu -I../sysdeps/x86_64 -I../sysdeps/wordsize-64 -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754 -I../sysdeps/generic/elf -I../sysdeps/generic -D_LIBC_REENTRANT -include ../include/libc-symbols.h -o /builds/glibc/tree-ssa/misc/readv.o -MD -MP -MF /builds/glibc/tree-ssa/misc/readv.o.dt -save-temps -v Reading specs from /opt/gcc/tree-ssa-20020619-branch/lib/gcc/x86_64-suse-linux-gnu/3.5-tree-ssa/specs Configured with: /cvs/gcc-tree-ssa-20020619-branch/configure --prefix=/opt/gcc/tree-ssa-20020619-branch --disable-nls --enable-threads=posix --enable-clocale=gnu --enable-__cxa_atexit --enable-shared --enable-languages=c,c++,java,f95,objc --with-system-zlib x86_64-suse-linux-gnu Thread model: posix gcc version 3.5-tree-ssa 20040322 (merged 20040307) /opt/gcc/tree-ssa-20020619-branch/libexec/gcc/x86_64-suse-linux-gnu/3.5-tree-ssa/cc1 -E -quiet -v -I../include -I. -I/builds/glibc/tree-ssa/misc -I.. -I../libio -I/builds/glibc/tree-ssa -I../sysdeps/x86_64/elf -I../linuxthreads/sysdeps/unix/sysv/linux/x86_64 -I../linuxthreads/sysdeps/unix/sysv/linux -I../linuxthreads/sysdeps/pthread -I../sysdeps/pthread -I../linuxthreads/sysdeps/unix/sysv -I../linuxthreads/sysdeps/unix -I../linuxthreads/sysdeps/x86_64 -I../libidn/sysdeps/unix -I../sysdeps/unix/sysv/linux/x86_64 -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/common -I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../sysdeps/unix/sysv -I../sysdeps/unix/x86_64 -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/x86_64/fpu -I../sysdeps/x86_64 -I../sysdeps/wordsize-64 -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754 -I../sysdeps/generic/elf -I../sysdeps/generic -MD /builds/glibc/tree-ssa/misc/readv.d -MF /builds/glibc/tree-ssa/misc/readv.o.dt -MP -MQ /builds/glibc/tree-ssa/misc/readv.o -D_LIBC_REENTRANT -include ../include/libc-symbols.h ../sysdeps/unix/sysv/linux/readv.c -mtune=k8 -std=gnu99 -Wall -Winline -Wstrict-prototypes -Wwrite-strings -fexceptions -fasynchronous-unwind-tables -fworking-directory -O2 -o readv.i ignoring nonexistent directory "/opt/gcc/tree-ssa-20020619-branch/lib/gcc/x86_64-suse-linux-gnu/3.5-tree-ssa/../../../../x86_64-suse-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: ../include . /builds/glibc/tree-ssa/misc .. ../libio /builds/glibc/tree-ssa ../sysdeps/x86_64/elf ../linuxthreads/sysdeps/unix/sysv/linux/x86_64 ../linuxthreads/sysdeps/unix/sysv/linux ../linuxthreads/sysdeps/pthread ../sysdeps/pthread ../linuxthreads/sysdeps/unix/sysv ../linuxthreads/sysdeps/unix ../linuxthreads/sysdeps/x86_64 ../libidn/sysdeps/unix ../sysdeps/unix/sysv/linux/x86_64 ../sysdeps/unix/sysv/linux ../sysdeps/gnu ../sysdeps/unix/common ../sysdeps/unix/mman ../sysdeps/unix/inet ../sysdeps/unix/sysv ../sysdeps/unix/x86_64 ../sysdeps/unix ../sysdeps/posix ../sysdeps/x86_64/fpu ../sysdeps/x86_64 ../sysdeps/wordsize-64 ../sysdeps/ieee754/ldbl-96 ../sysdeps/ieee754/dbl-64 ../sysdeps/ieee754/flt-32 ../sysdeps/ieee754 ../sysdeps/generic/elf ../sysdeps/generic /usr/local/include /opt/gcc/tree-ssa-20020619-branch/include /opt/gcc/tree-ssa-20020619-branch/lib/gcc/x86_64-suse-linux-gnu/3.5-tree-ssa/include /usr/include End of search list. /opt/gcc/tree-ssa-20020619-branch/libexec/gcc/x86_64-suse-linux-gnu/3.5-tree-ssa/cc1 -fpreprocessed readv.i -quiet -dumpbase readv.c -mtune=k8 -auxbase-strip /builds/glibc/tree-ssa/misc/readv.o -g -O2 -Wall -Winline -Wstrict-prototypes -Wwrite-strings -std=gnu99 -version -fexceptions -fasynchronous-unwind-tables -o readv.s GNU C version 3.5-tree-ssa 20040322 (merged 20040307) (x86_64-suse-linux-gnu) compiled by GNU C version 3.5-tree-ssa 20040322 (merged 20040307). GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 ../sysdeps/posix/readv.c: In function `__atomic_readv_replacement': ../sysdeps/posix/readv.c:35: error: Invalid operand to binary operator (long int<D3>)T.182<D6760>_122; ../sysdeps/posix/readv.c:35: internal compiler error: verify_stmts failed. Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Created attachment 5975 [details] Preprocessed source file
Most likely this is a dup of bug 14672.
I can reproduce this with 3.5-tree-ssa 20040318 (merged 20040307) (alphaev68-unknown-linux-gnu). Test case: int __atomic_readv_replacement(unsigned long iov_len, int count, int i) { unsigned long bytes = 0; while (i < count) { if (9223372036854775807L - bytes < iov_len) return 22; } return 0; }
Here is one which fails on 32bit targets: int __atomic_readv_replacement(unsigned long long iov_len, int count, int i) { unsigned long long bytes = 0; while (i < count) { if (9223372036854775807LL - bytes < iov_len) return 22; } return 0; }
DOM is causing it. Before DOM: ;; Function __atomic_readv_replacement (__atomic_readv_replacement) __atomic_readv_replacement (iov_len, count, i) { long long unsigned int bytes; long long unsigned int T.0; <bb 0>: bytes_1 = 0; goto <bb 3> (<L2>); <L0>:; T.0_5 = 9223372036854775807 - bytes_1; if (T.0_5 < iov_len_6) goto <L1>; else goto <L2>; <L1>:; return 22; <L2>:; if (i_2 < count_3) goto <L0>; else goto <L4>; <L4>:; return 0; } After DOM: ;; Function __atomic_readv_replacement (__atomic_readv_replacement) __atomic_readv_replacement (iov_len, count, i) { long long unsigned int bytes; long long unsigned int T.0; <bb 0>: bytes_1 = 0; goto <bb 3> (<L2>); <L0>:; T.0_5 = 9223372036854775807; if ((long long int)iov_len_6 < 0) goto <L1>; else goto <L2>; <L1>:; return 22; <L2>:; if (i_2 < count_3) goto <L0>; else goto <L4>; <L4>:; return 0; } See if ((long long int)iov_len_6 < 0) goto <L1>; else goto <L2>;
Yup, DOM1 is doing something really interesting here: Optimizing statement <L0>:; Optimizing statement T.0_5 = 9223372036854775807 - bytes_1; Replaced 'bytes<D1401>_1' with constant '0' Folded to: T.0_5 = 9223372036854775807; Optimizing statement if (T.0_5 < iov_len_6) goto <L1>; else goto <L2>; Replaced 'T.0<D1405>_5' with constant '9223372036854775807' Folded to: if ((long long int)iov_len_6 < 0) goto <L1>; else goto <L2>;
Actually it looks like DOM is not taking into the fact that fold can create non-gimple.
Perhaps. I looked in GDB: /* Const/copy propagate into USES, VUSES and the RHS of VDEFs. */ may_have_exposed_new_symbols = cprop_into_stmt (stmt, const_and_copies); ==> Here we have: "if (9223372036854775807 < iov_len_6) goto <L1>; else goto <L2>;" which is good. /* If the statement has been modified with constant replacements, fold its RHS before checking for redundant computations. */ if (ann->modified) { /* Try to fold the statement making sure that STMT is kept up to date. */ if (fold_stmt (bsi_stmt_ptr (si))) { ==> and here we have: "if ((long long int)iov_len_6 < 0) goto <L1>; else goto <L2>;" which is wrong. So fold_stmt is producing something we're not ready for.
In tree-ssa-ccp.c: /* If we couldn't fold the RHS, hand over to the generic fold routines. */ if (result == NULL_TREE) result = fold (rhs); After fold(rhs), we have: (gdb) p print_generic_stmt (stderr,result,0) (long long int)iov_len_6 < 0; So Andrew is right.
Here is a version which uses char instead of long/long long's: int __atomic_readv_replacement(unsigned char iov_len, int count, int i) { unsigned char bytes = 0; if ((unsigned char)((char)127 - bytes) < iov_len) return 22; return 0; } The problem is that fold is converting 127 < iov_len into (char)( iov_len) < 0 which is right but it is not gimple.
Subject: Re: [tree-ssa] error: Invalid operand to binary operator In message <20040322221127.1513.qmail@sources.redhat.com>, "pinskia at gcc dot gnu dot org" writes: > >------- Additional Comments From pinskia at gcc dot gnu dot org 2004-03-22 2 >2:11 ------- >Here is a version which uses char instead of long/long long's: >int __atomic_readv_replacement(unsigned char iov_len, int count, int i) { > unsigned char bytes = 0; > if ((unsigned char)((char)127 - bytes) < iov_len) > return 22; > return 0; >} > >The problem is that fold is converting 127 < iov_len into (char)( iov_len) < > 0 which is >right but it is not gimple. This is a known problem and already on my list of issues to address. jeff
This should be critical because it shows up in PR 8361: if ((long int)__n_7 < 0) goto <L1> ; else goto <L2>;
Really only the preprocessed source that is in the PR because maxsize is defined now as: size_type max_size() const { return size_type(-1) / sizeof(value_type); }
Subject: Re: [tree-ssa] error: Invalid operand to binary operator In message <20040323025330.29184.qmail@sources.redhat.com>, "pinskia at gcc dot gnu dot org" writes: > >------- Additional Comments From pinskia at gcc dot gnu dot org 2004-03-23 0 >2:53 ------- >This should be critical because it shows up in PR 8361: if ((long int)__n_7 < > 0) goto <L1> >; else goto <L2>; I know it affects 8361 -- that's how I found out about it in the first place! :-) jeff
A similar error breaks bootstrap on PPC32 AIX after the March 25/26 merge: /k42/dje/build/powerpc-ibm-aix5.1.0.0-20040326/powerpc-ibm-aix5.1.0.0/pthread/li bstdc++-v3/include/ext/pool_allocator.h: In member function `_Tp* __gnu_cxx::__p ool_alloc<_Tp>::allocate(size_t, const void*) [with _Tp = wchar_t]': /k42/dje/build/powerpc-ibm-aix5.1.0.0-20040326/powerpc-ibm-aix5.1.0.0/pthread/li bstdc++-v3/include/ext/pool_allocator.h:299: error: Invalid operand to binary op erator (long int<D5>)__n<D15188>_17; /k42/dje/build/powerpc-ibm-aix5.1.0.0-20040326/powerpc-ibm-aix5.1.0.0/pthread/li bstdc++-v3/include/ext/pool_allocator.h:299: internal compiler error: verify_stm ts failed.
This breaks bootstrap at least PPC32 and Cygwin since the latest merge.
law is working on a fix.
Subject: Re: [tree-ssa] error: Invalid operand to binary operator In message <20040322221127.1513.qmail@sources.redhat.com>, "pinskia at gcc dot gnu dot org" writes: > >------- Additional Comments From pinskia at gcc dot gnu dot org 2004-03-22 2 >2:11 ------- >Here is a version which uses char instead of long/long long's: >int __atomic_readv_replacement(unsigned char iov_len, int count, int i) { > unsigned char bytes = 0; > if ((unsigned char)((char)127 - bytes) < iov_len) > return 22; > return 0; >} > >The problem is that fold is converting 127 < iov_len into (char)( iov_len) < > 0 which is right but it is not gimple. Correct. This is the fault of fold_relational_hi_lo (and it's one of the reasons why I suggested to Kazu that he not try and merge it back to the mainline). I've got a hack which disables this behavior when we're in gimple form (Richard -- any progress on rewriting the folder around the design we discussed a couple weeks ago?) Additionally, I noticed that fold_stmt in tree-ssa-ccp.c was not checking return values as closely as it should. I fixed that too. Finally, while working on improving the way we handle updating the SSA graph after jump threading I noticed two places where we could stop walking down the list of PHI nodes when we really should have kept going. I haven't been able to trigger a real failure due to this bug, but it clearly needs to be fixed. Bootstrapped and regression tested on i686-pc-linux-gnu. I'll check in the simplified testcase fir 14682 shortly. * fold-const.c (fold_relational_hi_lo): Do not return non-gimple code when we are in gimple form. * tree-optimize.c (tree_rest_of_compilation): Note when we are in gimple form. * tree-ssa-ccp.c (ccp_fold): Tighten tests on return value from nondestructive_fold_{unary,binary}to_constant. * tree.h (in_gimple_form): Declare. * tree-ssa.c (ssa_remove_edge): Correct looping structure. (ssa_redirect_edge): Similarly Index: fold-const.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v retrieving revision 1.213.2.82 diff -c -p -r1.213.2.82 fold-const.c *** fold-const.c 26 Mar 2004 16:22:07 -0000 1.213.2.82 --- fold-const.c 1 Apr 2004 17:03:59 -0000 *************** fold_relational_hi_lo (enum tree_code *c *** 9072,9077 **** --- 9072,9084 ---- TREE_TYPE (exp), TREE_OPERAND (exp, 0), TREE_OPERAND (exp, 1)); + + /* If we are in gimple form, then returning EXP would create + non-gimple expressions. Clearing it is safe and insures + we do not allow a non-gimple expression to escape. */ + if (in_gimple_form) + exp = NULL; + return (retval ? retval : exp); } } Index: tree-optimize.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/tree-optimize.c,v retrieving revision 1.1.4.135 diff -c -p -r1.1.4.135 tree-optimize.c *** tree-optimize.c 26 Mar 2004 16:22:28 -0000 1.1.4.135 --- tree-optimize.c 1 Apr 2004 17:04:01 -0000 *************** Boston, MA 02111-1307, USA. */ *** 52,57 **** --- 52,58 ---- /* Global variables used to communicate with passes. */ int dump_flags; bitmap vars_to_rename; + bool in_gimple_form; /* The root of the compilation pass tree, once constructed. */ static struct tree_opt_pass *all_passes; *************** tree_rest_of_compilation (tree fndecl, b *** 522,529 **** --- 523,537 ---- } } + /* Note that the folders should only create gimple expressions. + This is a hack until the new folder is ready. */ + in_gimple_form = 1; + /* Perform all tree transforms and optimizations. */ execute_pass_list (all_passes); + + /* Note that the folders can create non-gimple expressions again. */ + in_gimple_form = 1; /* If the function has a variably modified type, there may be SAVE_EXPRs in the parameter types. Their context must be set to Index: tree-ssa-ccp.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-ccp.c,v retrieving revision 1.1.2.148 diff -c -p -r1.1.2.148 tree-ssa-ccp.c *** tree-ssa-ccp.c 16 Mar 2004 22:31:55 -0000 1.1.2.148 --- tree-ssa-ccp.c 1 Apr 2004 17:04:04 -0000 *************** ccp_fold (tree stmt) *** 806,811 **** --- 806,816 ---- TREE_TYPE (rhs), op0); + /* If we folded, but did not create an invariant, then we can not + use this expression. */ + if (retval && ! is_gimple_min_invariant (retval)) + return NULL; + /* If we could not fold the expression, but the arguments are all constants and gimple values, then build and return the new expression. *************** ccp_fold (tree stmt) *** 854,859 **** --- 859,869 ---- TREE_TYPE (rhs), op0, op1); + /* If we folded, but did not create an invariant, then we can not + use this expression. */ + if (retval && ! is_gimple_min_invariant (retval)) + return NULL; + /* If we could not fold the expression, but the arguments are all constants and gimple values, then build and return the new expression. Index: tree-ssa.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa.c,v retrieving revision 1.1.4.216 diff -c -p -r1.1.4.216 tree-ssa.c *** tree-ssa.c 19 Mar 2004 02:07:25 -0000 1.1.4.216 --- tree-ssa.c 1 Apr 2004 17:04:06 -0000 *************** Boston, MA 02111-1307, USA. */ *** 53,63 **** void ssa_remove_edge (edge e) { ! tree phi; /* Remove the appropriate PHI arguments in E's destination block. */ ! for (phi = phi_nodes (e->dest); phi; phi = TREE_CHAIN (phi)) ! remove_phi_arg (phi, e->src); remove_edge (e); } --- 53,66 ---- void ssa_remove_edge (edge e) { ! tree phi, next; /* Remove the appropriate PHI arguments in E's destination block. */ ! for (phi = phi_nodes (e->dest); phi; phi = next) ! { ! next = TREE_CHAIN (phi); ! remove_phi_arg (phi, e->src); ! } remove_edge (e); } *************** ssa_remove_edge (edge e) *** 69,82 **** edge ssa_redirect_edge (edge e, basic_block dest) { ! tree phi; tree list = NULL, *last = &list; tree src, dst, node; int i; /* Remove the appropriate PHI arguments in E's destination block. */ ! for (phi = phi_nodes (e->dest); phi; phi = TREE_CHAIN (phi)) { i = phi_arg_from_edge (phi, e); if (i < 0) continue; --- 72,87 ---- edge ssa_redirect_edge (edge e, basic_block dest) { ! tree phi, next; tree list = NULL, *last = &list; tree src, dst, node; int i; /* Remove the appropriate PHI arguments in E's destination block. */ ! for (phi = phi_nodes (e->dest); phi; phi = next) { + next = TREE_CHAIN (phi); + i = phi_arg_from_edge (phi, e); if (i < 0) continue; Index: tree.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/tree.h,v retrieving revision 1.342.2.180 diff -c -p -r1.342.2.180 tree.h *** tree.h 26 Mar 2004 16:22:30 -0000 1.342.2.180 --- tree.h 1 Apr 2004 17:04:12 -0000 *************** typedef enum *** 3757,3761 **** --- 3757,3766 ---- extern int tree_node_counts[]; extern int tree_node_sizes[]; + + /* True if we are in gimple form and the actions of the folders need to + be restricted. False if we are not in gimple form and folding is not + restricted to creating gimple expressions. */ + extern bool in_gimple_form; #endif /* GCC_TREE_H */ jeff
Should be fixed by today's changes.
Subject: Re: [tree-ssa] error: Invalid operand to binary operator On Thu, Apr 01, 2004 at 10:32:08AM -0700, law@redhat.com wrote: > (Richard -- any progress on rewriting the folder around the design we > discussed a couple weeks ago?) No, not yet. :-( r~
Subject: Re: [tree-ssa] error: Invalid operand to binary operator On Thu, Apr 01, 2004 at 10:32:08AM -0700, law@redhat.com wrote: > + /* Note that the folders should only create gimple expressions. > + This is a hack until the new folder is ready. */ > + in_gimple_form = 1; > + > /* Perform all tree transforms and optimizations. */ > execute_pass_list (all_passes); > + > + /* Note that the folders can create non-gimple expressions again. */ > + in_gimple_form = 1; Typo second time. r~
Subject: Re: [tree-ssa] error: Invalid operand to binary operator In message <20040401182528.GB30425@redhat.com>, Richard Henderson writes: >On Thu, Apr 01, 2004 at 10:32:08AM -0700, law@redhat.com wrote: >> + /* Note that the folders should only create gimple expressions. >> + This is a hack until the new folder is ready. */ >> + in_gimple_form = 1; >> + >> /* Perform all tree transforms and optimizations. */ >> execute_pass_list (all_passes); >> + >> + /* Note that the folders can create non-gimple expressions again. */ >> + in_gimple_form = 1; > >Typo second time. Thanks. Brain fart. I also changed them to use true/false respectively. jeff
Subject: Re: [tree-ssa] error: Invalid operand to binary operator On Thu, 2004-04-01 at 13:40, law at redhat dot com wrote: > >> + /* Note that the folders should only create gimple expressions. > >> + This is a hack until the new folder is ready. */ > >> + in_gimple_form = 1; > >> + > >> /* Perform all tree transforms and optimizations. */ > >> execute_pass_list (all_passes); > >> + > >> + /* Note that the folders can create non-gimple expressions again. */ > >> + in_gimple_form = 1; > > > >Typo second time. > Thanks. Brain fart. I also changed them to use true/false respectively. > Oh, heh. We were all looking at the same thing then. I committed the obvious fix a few minutes ago. Diego.
Subject: Re: [tree-ssa] error: Invalid operand to binary operator In message <20040401184237.14302.qmail@sources.redhat.com>, "dnovillo at redhat dot com" writes: > >------- Additional Comments From dnovillo at redhat dot com 2004-04-01 18:42 > ------- >Subject: Re: [tree-ssa] error: Invalid operand to > binary operator > >On Thu, 2004-04-01 at 13:40, law at redhat dot com wrote: > >> >> + /* Note that the folders should only create gimple expressions. >> >> + This is a hack until the new folder is ready. */ >> >> + in_gimple_form = 1; >> >> + >> >> /* Perform all tree transforms and optimizations. */ >> >> execute_pass_list (all_passes); >> >> + >> >> + /* Note that the folders can create non-gimple expressions again. >*/ >> >> + in_gimple_form = 1; >> > >> >Typo second time. >> Thanks. Brain fart. I also changed them to use true/false respectively. >> >Oh, heh. We were all looking at the same thing then. I committed the >obvious fix a few minutes ago. Yea, you beat me to the commit... jeff