/home/uros/gcc-build/./prev-gcc/xg++ -B/home/uros/gcc-build/./prev-gcc/ -B/usr/local/alphaev68-unknown-linux-gnu/bin/ -nostdinc++ -B/home/uros/gcc-build/prev-alphaev68-unknown-linux-gnu/libstdc++-v3/src/.libs -B/home/uros/gcc-build/prev-alphaev68-unknown-linux-gnu/libstdc++-v3/libsupc++/.libs -I/home/uros/gcc-build/prev-alphaev68-unknown-linux-gnu/libstdc++-v3/include/alphaev68-unknown-linux-gnu -I/home/uros/gcc-build/prev-alphaev68-unknown-linux-gnu/libstdc++-v3/include -I/home/uros/gcc-svn/trunk/libstdc++-v3/libsupc++ -L/home/uros/gcc-build/prev-alphaev68-unknown-linux-gnu/libstdc++-v3/src/.libs -L/home/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 -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 wide-int.o -MT wide-int.o -MMD -MP -MF ./.deps/wide-int.TPo ../../gcc-svn/trunk/gcc/wide-int.cc In file included from ../../gcc-svn/trunk/gcc/wide-int.cc:37:0: ../../gcc-svn/trunk/gcc/wide-int.cc: In function ‘unsigned int wi::mul_internal(long int*, const long int*, unsigned int, const long int*, unsigned int, unsigned int, signop, bool*, bool)’: ../../gcc-svn/trunk/gcc/../include/longlong.h:145:10: sorry, unimplemented: unexpected AST of kind mult_highpart_expr (ph) = __builtin_alpha_umulh (__m0, __m1); \ ^ ../../gcc-svn/trunk/gcc/wide-int.cc:1269:4: note: in expansion of macro ‘umul_ppmm’ umul_ppmm (val[1], val[0], op1.ulow (), op2.ulow ()); ^ ../../gcc-svn/trunk/gcc/../include/longlong.h:145:10: internal compiler error: in potential_constant_expression_1, at cp/semantics.c:10575 (ph) = __builtin_alpha_umulh (__m0, __m1); \ ^ ../../gcc-svn/trunk/gcc/wide-int.cc:1269:4: note: in expansion of macro ‘umul_ppmm’ umul_ppmm (val[1], val[0], op1.ulow (), op2.ulow ()); ^ 0x12047846f potential_constant_expression_1 ../../gcc-svn/trunk/gcc/cp/semantics.c:10575 0x1204784bb potential_constant_expression(tree_node*) ../../gcc-svn/trunk/gcc/cp/semantics.c:10585 0x12047555f maybe_constant_value(tree_node*) ../../gcc-svn/trunk/gcc/cp/semantics.c:9930 0x1203e9e3f cp_convert_and_check(tree_node*, tree_node*, int) ../../gcc-svn/trunk/gcc/cp/cvt.c:630 0x1201819d7 convert_like_real ../../gcc-svn/trunk/gcc/cp/call.c:6345 0x1201925af perform_implicit_conversion_flags(tree_node*, tree_node*, int, int) ../../gcc-svn/trunk/gcc/cp/call.c:9109 0x1203dffb3 convert_for_assignment ../../gcc-svn/trunk/gcc/cp/typeck.c:8163 ...
Created attachment 32751 [details] Preprocessed source Fails with -O2.
The failure can be triggered with an attached precompiled source using a crosscompiler from x86-64 to alphaev68-pc-linux-gnu, with -O2: ~/gcc-build-xxx/gcc/cc1plus -O2 -quiet wide-int.ii cc1plus: error: no include path in which to search for stdc-predef.h ../../gcc-svn/trunk/gcc/wide-int.cc: In function ‘unsigned int wi::mul_internal(long int*, const long int*, unsigned int, const long int*, unsigned int, unsigned int, signop, bool*, bool)’: ../../gcc-svn/trunk/gcc/wide-int.cc:1269:70: sorry, unimplemented: unexpected AST of kind mult_highpart_expr ../../gcc-svn/trunk/gcc/wide-int.cc:1269:70: internal compiler error: in potential_constant_expression_1, at cp/semantics.c:10575 0x6a1a3f potential_constant_expression_1 ../../gcc-svn/trunk/gcc/cp/semantics.c:10575 0x6a9c2c potential_constant_expression(tree_node*) ../../gcc-svn/trunk/gcc/cp/semantics.c:10585 0x6a9cb3 maybe_constant_value(tree_node*) ../../gcc-svn/trunk/gcc/cp/semantics.c:9927 ...
If I remember well, this sounds like a problem that has been seen on aarch64 in the past: http://gcc.gnu.org/ml/gcc-patches/2013-04/msg00586.html (and the whole thread) http://gcc.gnu.org/ml/gcc-patches/2013-04/msg01503.html So, this looks like an alpha backend bug, where it should do some (or all?) the foldings of md builtins in gimple_fold_builtin hook rather than fold_builtin.
Jakub, what do you think about following c++ patch: --cut here-- Index: semantics.c =================================================================== --- semantics.c (revision 210137) +++ semantics.c (working copy) @@ -9630,6 +9630,7 @@ cxx_eval_constant_expression (const constexpr_call case PLUS_EXPR: case MINUS_EXPR: case MULT_EXPR: + case MULT_HIGHPART_EXPR: case TRUNC_DIV_EXPR: case CEIL_DIV_EXPR: case FLOOR_DIV_EXPR: @@ -10484,6 +10485,7 @@ potential_constant_expression_1 (tree t, bool want case PLUS_EXPR: case MULT_EXPR: + case MULT_HIGHPART_EXPR: case POINTER_PLUS_EXPR: case RDIV_EXPR: case EXACT_DIV_EXPR: --cut here-- This patch fixes the compilation of the testcase and allows native alpha bootstrap to continue.
See the discussions, this is a step in a bad direction, the backend builtins should be folded only during gimplification (i.e. the gimple_fold_builtin targhook), unless folding them is required e.g. for C++11 constexprs etc. If folding them is solely an optimization or implementation of those builtins, then the FE should see them just as calls and only later on they should be folded.
IMHO fold_builtin should go away entirely in favor of gimple_fold_builtin.
Created attachment 32757 [details] Proposed patch that implements TARGET_GIMPLE_FOLD_BUILTIN for alpha I am testing the attached patch.
Patch at [1]. [1] http://gcc.gnu.org/ml/gcc-patches/2014-05/msg00493.html
Author: uros Date: Thu May 8 19:02:28 2014 New Revision: 210233 URL: http://gcc.gnu.org/viewcvs?rev=210233&root=gcc&view=rev Log: PR target/61092 * config/alpha/alpha.c: Include gimple-iterator.h. (alpha_gimple_fold_builtin): New function. Move ALPHA_BUILTIN_UMULH folding from ... (alpha_fold_builtin): ... here. (TARGET_GIMPLE_FOLD_BUILTIN): New define. Modified: trunk/gcc/ChangeLog trunk/gcc/config/alpha/alpha.c
Author: uros Date: Fri May 9 15:02:09 2014 New Revision: 210278 URL: http://gcc.gnu.org/viewcvs?rev=210278&root=gcc&view=rev Log: Backport from mainline 2014-05-08 Uros Bizjak <ubizjak@gmail.com> PR target/61092 * config/alpha/alpha.c: Include gimple-iterator.h. (alpha_gimple_fold_builtin): New function. Move ALPHA_BUILTIN_UMULH folding from ... (alpha_fold_builtin): ... here. (TARGET_GIMPLE_FOLD_BUILTIN): New define. Modified: branches/gcc-4_9-branch/gcc/ChangeLog branches/gcc-4_9-branch/gcc/config/alpha/alpha.c
Fixed.