target: m32c-elf test case: cc1 -O3 -mcpu=m32c dj.c -------------------- void cyg_hal_plf_serial_write(void* __ch_data, const unsigned char* __buf, unsigned long __len) { while(__len-- > 0) cyg_hal_plf_serial_putc(__ch_data, *__buf++); } --------------------
We get here, and fold_binary returns NULL: 13560 tem = fold_binary (code, type, op0, op1); 13561 if (!tem) 13562 tem = build2_stat (code, type, op0, op1 PASS_MEM_STAT); so it calls build2_stat, but fails at this assert: 3108 if ((code == MINUS_EXPR || code == PLUS_EXPR || code == MULT_EXPR) 3109 && arg0 && arg1 && tt && POINTER_TYPE_P (tt)) 3110 gcc_assert (TREE_CODE (arg0) == INTEGER_CST && TREE_CODE (arg1) == INTEGER_CST); traceback, tt, and ops follow. Why is this going wrong? Note that m32c pointers are PSImode (24 bits), int/size_t are 16 bits, and long is 32 bits. #1 0x08827a01 in build2_stat (code=PLUS_EXPR, tt=0xb7f5d2f4, arg0=0xb7f5f6e0, arg1=0xb7f61c30) at ../../gcc/gcc/tree.c:3110 #2 0x08387ccb in fold_build2_stat (code=PLUS_EXPR, type=0xb7f5d2f4, op0=0xb7f5f6e0, op1=0xb7f61c30) at ../../gcc/gcc/fold-const.c:13562 #3 0x0834d43b in fold_binary (code=PLUS_EXPR, type=0xb7f5d2f4, op0=0xb7f61c30, op1=0xb7f5f6e0) at ../../gcc/gcc/fold-const.c:9555 #4 0x08387ca2 in fold_build2_stat (code=PLUS_EXPR, type=0xb7f5d2f4, op0=0xb7f61c30, op1=0xb7f5f6e0) at ../../gcc/gcc/fold-const.c:13560 #5 0x086d3bc2 in create_mem_ref (bsi=0xbfcc617c, type=0xb7f5d288, addr=0xbfcc6188) at ../../gcc/gcc/tree-ssa-address.c:641 #6 0x0874bf9b in rewrite_use_address (data=0xbfcc62b8, use=0x8e76510, cand=0x8ecd640) at ../../gcc/gcc/tree-ssa-loop-ivopts.c:5089 #7 0x0874c29f in rewrite_use (data=0xbfcc62b8, use=0x8e76510, cand=0x8ecd640) at ../../gcc/gcc/tree-ssa-loop-ivopts.c:5148 #8 0x0874c350 in rewrite_uses (data=0xbfcc62b8) at ../../gcc/gcc/tree-ssa-loop-ivopts.c:5177 #9 0x0874ccb4 in tree_ssa_iv_optimize_loop (data=0xbfcc62b8, loop=0xb7f6833c) at ../../gcc/gcc/tree-ssa-loop-ivopts.c:5347 #10 0x0874cd4d in tree_ssa_iv_optimize () at ../../gcc/gcc/tree-ssa-loop-ivopts.c:5380 #11 0x08760d74 in tree_ssa_loop_ivopts () at ../../gcc/gcc/tree-ssa-loop.c:549 #12 0x084811e2 in execute_one_pass (pass=0x8c3dfc0) at ../../gcc/gcc/passes.c:1116 #13 0x0848132e in execute_pass_list (pass=0x8c3dfc0) at ../../gcc/gcc/passes.c:1169 #14 0x0848134a in execute_pass_list (pass=0x8c3dc00) at ../../gcc/gcc/passes.c:1170 #15 0x0848134a in execute_pass_list (pass=0x8c3d400) at ../../gcc/gcc/passes.c:1170 #16 0x086810ea in tree_rest_of_compilation (fndecl=0xb7f5bb80) at ../../gcc/gcc/tree-optimize.c:404 #17 0x088a3a19 in cgraph_expand_function (node=0xb7f5bc80) at ../../gcc/gcc/cgraphunit.c:1070 #18 0x088a3c13 in cgraph_expand_all_functions () at ../../gcc/gcc/cgraphunit.c:1139 #19 0x088a422e in cgraph_optimize () at ../../gcc/gcc/cgraphunit.c:1346 #20 0x08076156 in c_write_global_declarations () at ../../gcc/gcc/c-decl.c:8077 #21 0x085f66dd in compile_file () at ../../gcc/gcc/toplev.c:1052 #22 0x085f81b5 in do_compile () at ../../gcc/gcc/toplev.c:2235 #23 0x085f8217 in toplev_main (argc=4, argv=0xbfcc6644) at ../../gcc/gcc/toplev.c:2267 #24 0x08121e7a in main (argc=...) at ../../gcc/gcc/main.c:35 [ gdb ] call debug_tree(tt) <pointer_type 0xb7f5d2f4 type <integer_type 0xb7f5d288 unsigned char readonly unsigned string-flag QI size <integer_cst 0xb7eee2d8 constant invariant 8> unit size <integer_cst 0xb7eee2f4 constant invariant 1> align 8 symtab 0 alias set -1 canonical type 0xb7f5d288 precision 8 min <integer_cst 0xb7eee310 0> max <integer_cst 0xb7eee32c 255> pointer_to_this <pointer_type 0xb7f5d2f4>> public unsigned PSI size <integer_cst 0xb7eee4d0 type <integer_type 0xb7efc06c bit_size_type> constant invariant 32> unit size <integer_cst 0xb7eee24c type <integer_type 0xb7efc000 long unsigned int> constant invariant 4> align 8 symtab 0 alias set -1 canonical type 0xb7f5d2f4> [ gdb ] call debug_tree(arg0) <nop_expr 0xb7f5f6e0 type <pointer_type 0xb7f5d2f4 type <integer_type 0xb7f5d288 unsigned char readonly unsigned string-flag QI size <integer_cst 0xb7eee2d8 constant invariant 8> unit size <integer_cst 0xb7eee2f4 constant invariant 1> align 8 symtab 0 alias set -1 canonical type 0xb7f5d288 precision 8 min <integer_cst 0xb7eee310 0> max <integer_cst 0xb7eee32c 255> pointer_to_this <pointer_type 0xb7f5d2f4>> public unsigned PSI size <integer_cst 0xb7eee4d0 constant invariant 32> unit size <integer_cst 0xb7eee24c constant invariant 4> align 8 symtab 0 alias set -1 canonical type 0xb7f5d2f4> arg 0 <ssa_name 0xb7f61b94 type <integer_type 0xb7efc438 long unsigned int public unsigned SI size <integer_cst 0xb7eee4d0 32> unit size <integer_cst 0xb7eee24c 4> align 8 symtab 0 alias set -1 canonical type 0xb7efc438 precision 32 min <integer_cst 0xb7eee4ec 0> max <integer_cst 0xb7eee4b4 4294967295>> var <var_decl 0xb7f6861c ivtmp.19> def_stmt <phi_node 0xb7f69000> version 1>> [ gdb ] call debug_tree(arg1) <ssa_name 0xb7f61c30 type <pointer_type 0xb7f5d2f4 type <integer_type 0xb7f5d288 unsigned char readonly unsigned string-flag QI size <integer_cst 0xb7eee2d8 constant invariant 8> unit size <integer_cst 0xb7eee2f4 constant invariant 1> align 8 symtab 0 alias set -1 canonical type 0xb7f5d288 precision 8 min <integer_cst 0xb7eee310 0> max <integer_cst 0xb7eee32c 255> pointer_to_this <pointer_type 0xb7f5d2f4>> public unsigned PSI size <integer_cst 0xb7eee4d0 constant invariant 32> unit size <integer_cst 0xb7eee24c constant invariant 4> align 8 symtab 0 alias set -1 canonical type 0xb7f5d2f4> volatile visited var <parm_decl 0xb7ef70fc __buf> def_stmt <nop_expr 0xb7f5f240> version 4 ptr-info 0xb7ef3f90>