This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/17965] New: ice in expand_call
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Oct 2004 02:34:10 -0000
- Subject: [Bug middle-end/17965] New: ice in expand_call
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
template < typename atom, int n > struct StrassenMatrix {
atom data[n][n];
StrassenMatrix < atom, n / 2 > operator() (int a, int b) {
StrassenMatrix < atom, n / 2 > result;
int offs_i = a * n / 2;
int offs_j = b * n / 2;
for (int i = 0; i < n / 2; i++)
for (int j = 0; j < n / 2; j++)
result.data[i][j] = data[i + offs_i][j + offs_j];
return result;
}
StrassenMatrix operator+(StrassenMatrix m) {
StrassenMatrix result;
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
result.data[i][j] = data[i][j] + m.data[i][j];
return result;
}
StrassenMatrix operator-(StrassenMatrix m) {
StrassenMatrix result;
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
result.data[i][j] = data[i][j] - m.data[i][j];
return result;
}
StrassenMatrix operator*(StrassenMatrix m2) {
StrassenMatrix result;
StrassenMatrix < atom, n / 2 > p1, p2, p3, p4, p5, p6, p7;
StrassenMatrix m1 = *this;
p1 = (m1(0, 1) - m1(1, 1)) * (m2(1, 0) + m2(1, 1));
p2 = (m1(0, 0) + m1(1, 1)) * (m2(0, 0) + m2(1, 1));
p3 = (m1(0, 0) - m1(1, 0)) * (m2(0, 0) + m2(0, 1));
p4 = (m1(0, 0) + m1(0, 1)) * m2(1, 1);
p5 = m1(0, 0) * (m2(0, 1) - m2(1, 1));
p6 = m1(1, 1) * (m2(1, 0) - m2(0, 0));
p7 = (m1(1, 0) + m1(1, 1)) * m2(0, 0);
int nhalf = n / 2;
for (int i = 0; i < nhalf; i++) {
for (int j = 0; j < nhalf; j++) {
result.data[i][j] =
p1.data[i][j] + p2.data[i][j] - p4.data[i][j] +
p6.data[i][j];
result.data[i][j + nhalf] =
p4.data[i][j] + p5.data[i][j];
result.data[i + nhalf][j] =
p6.data[i][j] + p7.data[i][j];
result.data[i + nhalf][j + nhalf] =
p2.data[i][j] - p3.data[i][j] + p5.data[i][j] -
p7.data[i][j];
}
}
return result;
}
atom* elem(int i, int j) {
return &data[i][j];
}
};
template < typename atom > struct StrassenMatrix <atom, 1 > {
atom data[1][1];
StrassenMatrix operator+(StrassenMatrix m) {
StrassenMatrix result;
result.data[0][0] = data[0][0] + m.data[0][0];
return result;
}
StrassenMatrix operator-(StrassenMatrix m) {
StrassenMatrix result;
result.data[0][0] = data[0][0] - m.data[0][0];
return result;
}
StrassenMatrix operator*(StrassenMatrix m) {
StrassenMatrix result;
result.data[0][0] = data[0][0] * m.data[0][0];
return result;
}
atom* elem(int i, int j) {
return &data[i][j];
}
};
#define NUMTYPE double
template<int dim>
void test() {
// Initialisierung
StrassenMatrix < NUMTYPE, dim > strassen1, strassen2, strassenResult;
for (int i = 0; i < dim; i++)
for (int j = 0; j < dim; j++) {
*strassen1.elem(i,j) =
(NUMTYPE) (10.0 * rand() / (RAND_MAX + 1.0));
*strassen2.elem(i,j) =
(NUMTYPE) (10.0 * rand() / (RAND_MAX + 1.0));
}
// 5. Feld: Zeit fuer StrassenMatrix
strassenResult = strassen1 * strassen2;
}
int main(int argc, char **argv)
{
srand(0);
for (int i = 0; i < 5; i++) test<64>();
for (int i = 0; i < 5; i++) test<128>();
for (int i = 0; i < 5; i++) test<256>();
for (int i = 0; i < 5; i++) test<512>();
// ---*** HERE ***---
// As soon as I uncomment the following line, g++ will seg fault.
// for (int i = 0; i < 5; i++) test<1024>();
return 0;
}
--------------------------------------------
Confirmed, this is a middle-end problem on the mainline:
#0 0x003f13ec in expand_call (exp=0x42901a00, target=0xf15798, ignore=0) at /Users/pinskia/src/
local1/gcc/gcc/calls.c:2351
#1 0x004f3874 in expand_expr_real_1 (exp=0x42901a00, target=0xf15798, tmode=BLKmode,
modifier=EXPAND_NORMAL, alt_rtl=0xbfffef94) at /Users/pinskia/src/local1/gcc/gcc/expr.c:7242
#2 0x004ec518 in expand_expr_real (exp=0x42901a00, target=0xf15798, tmode=BLKmode,
modifier=EXPAND_NORMAL, alt_rtl=0xbfffef94) at /Users/pinskia/src/local1/gcc/gcc/expr.c:6314
#3 0x004dd2b8 in store_expr (exp=0x42901a00, target=0xf15798, want_value=0) at /Users/pinskia/
src/local1/gcc/gcc/expr.c:3933
#4 0x004dbfd4 in expand_assignment (to=0xb967c0, from=0x42901a00, want_value=0) at /Users/
pinskia/src/local1/gcc/gcc/expr.c:3746
#5 0x00500338 in expand_expr_real_1 (exp=0xb94480, target=0x0, tmode=VOIDmode,
modifier=EXPAND_NORMAL, alt_rtl=0x0) at /Users/pinskia/src/local1/gcc/gcc/expr.c:8112
#6 0x004ec518 in expand_expr_real (exp=0xb94480, target=0x4280d300, tmode=VOIDmode,
modifier=EXPAND_NORMAL, alt_rtl=0x0) at /Users/pinskia/src/local1/gcc/gcc/expr.c:6314
#7 0x007a5764 in expand_expr (exp=0xb94480, target=0x4280d300, mode=VOIDmode,
modifier=EXPAND_NORMAL) at /Users/pinskia/src/local1/gcc/gcc/expr.h:493
#8 0x0079c4c4 in expand_expr_stmt (exp=0xb94480) at /Users/pinskia/src/local1/gcc/gcc/stmt.c:
1354
#9 0x00823a74 in expand_gimple_basic_block (bb=0xc25b24, dump_file=0x0) at /Users/pinskia/src/
local1/gcc/gcc/cfgexpand.c:1126
#10 0x008243b4 in tree_expand_cfg () at /Users/pinskia/src/local1/gcc/gcc/cfgexpand.c:1299
#11 0x002bb75c in execute_one_pass (pass=0xac30f4) at /Users/pinskia/src/local1/gcc/gcc/tree-
optimize.c:503
#12 0x002bb8a8 in execute_pass_list (pass=0xac30f4) at /Users/pinskia/src/local1/gcc/gcc/tree-
optimize.c:538
#13 0x002bbcac in tree_rest_of_compilation (fndecl=0x42905f04) at /Users/pinskia/src/local1/gcc/
gcc/tree-optimize.c:633
#14 0x001b4e9c in expand_body (fn=0x42905f04) at /Users/pinskia/src/local1/gcc/gcc/cp/
semantics.c:2912
#15 0x00864ff0 in cgraph_expand_function (node=0x42906000) at /Users/pinskia/src/local1/gcc/
gcc/cgraphunit.c:1046
#16 0x0086aaa0 in cgraph_expand_all_functions () at /Users/pinskia/src/local1/gcc/gcc/cgraphunit.c:
2728
#17 0x0086b048 in cgraph_optimize () at /Users/pinskia/src/local1/gcc/gcc/cgraphunit.c:2839
#18 0x001121d8 in cp_finish_file () at /Users/pinskia/src/local1/gcc/gcc/cp/decl2.c:3067
#19 0x00002764 in finish_file () at /Users/pinskia/src/local1/gcc/gcc/cp/cp-lang.c:136
#20 0x00266c28 in c_common_parse_file (set_yydebug=0) at /Users/pinskia/src/local1/gcc/gcc/c-
opts.c:1096
#21 0x007b8f9c in compile_file () at /Users/pinskia/src/local1/gcc/gcc/toplev.c:985
#22 0x007bbc3c in do_compile () at /Users/pinskia/src/local1/gcc/gcc/toplev.c:2069
#23 0x007bbcd8 in toplev_main (argc=2, argv=0xbffffd90) at /Users/pinskia/src/local1/gcc/gcc/
toplev.c:2101
#24 0x0027e094 in main (argc=2, argv=0xbffffd90) at /Users/pinskia/src/local1/gcc/gcc/main.c:35
stack_usage_map = alloca (highest_outgoing_arg_in_use);
highest_outgoing_arg_in_use is 8388624, maybe it is time to allocate it on the heap instead of the
stack.
--
Summary: ice in expand_call
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Keywords: ice-on-valid-code
Severity: normal
Priority: P2
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pinskia at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: powerpc-darwin
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17965