> I don't think this is a suitable general solution. Can you instead try the > attached which again tries to simply make sure we sign-extend a sizetype > offset if that is smaller than the pointer mode.
Now I'm getting a ton of errors (like, around 5000) that look like this: [ gdb ] up #1 0x0854aca0 in build2_stat (code=PLUS_EXPR, tt=0xb7efc680, arg0=0xb7f76420, arg1=0xb7f717fc) at ../../gcc/gcc/tree.c:3293 3293 gcc_assert (TREE_CODE (arg0) == INTEGER_CST && TREE_CODE (arg1) == INTEGER_CST); [ gdb ] call debug_tree(arg0) <addr_expr 0xb7f76420 type <pointer_type 0xb7efc680 type <integer_type 0xb7ef52d8 int sizes-gimplified public HI size <integer_cst 0xb7ee7428 constant 16> unit size <integer_cst 0xb7ee7444 constant 2> align 8 symtab 0 alias set 2 canonical type 0xb7ef52d8 precision 16 min <integer_cst 0xb7ee747c -32768> max <integer_cst 0xb7ee7498 32767> pointer_to_this <pointer_type 0xb7efc680>> unsigned PSI size <integer_cst 0xb7ee7540 constant 32> unit size <integer_cst 0xb7ee72bc constant 4> align 8 symtab 0 alias set -1 canonical type 0xb7efc680> constant arg 0 <var_decl 0xb7f6c420 test_var.48 type <integer_type 0xb7ef52d8 int> used static ignored HI file /greed/dj/m32c/gcc/gcc/gcc/testsuite/gcc.dg/tree-ssa/predcom-1.c line 10 col 6 size <integer_cst 0xb7ee7428 16> unit size <integer_cst 0xb7ee7444 2> align 8 (mem:HI (symbol_ref:PSI ("test_var.48") [flags 0x2] <var_decl 0xb7f6c420 test_var.48>) [0 S2 A8])>> [ gdb ] call debug_tree(arg1) <integer_cst 0xb7f717fc type <pointer_type 0xb7efc680> constant 2000> [ gdb ] where #0 fancy_abort (file=0x87b9369 "../../gcc/gcc/tree.c", line=3293, function=0x87b8e84 "build2_stat") at ../../gcc/gcc/diagnostic.c:712 #1 0x0854aca0 in build2_stat (code=PLUS_EXPR, tt=0xb7efc680, arg0=0xb7f76420, arg1=0xb7f717fc) at ../../gcc/gcc/tree.c:3293 #2 0x081dd315 in expand_expr_real_1 (exp=0xb7f734c8, target=0x0, tmode=PSImode, modifier=EXPAND_NORMAL, alt_rtl=0x0) at ../../gcc/gcc/expr.c:8330 #3 0x081edc48 in expand_expr_real (exp=0xb7f734c8, target=0x0, tmode=PSImode, modifier=EXPAND_NORMAL, alt_rtl=0x0) at ../../gcc/gcc/expr.c:7121 #4 0x08494789 in computation_cost (expr=0xb7f734c8, speed=0 '\0') at ../../gcc/gcc/expr.h:538 #5 0x084975b7 in force_expr_to_var_cost (expr=0xb7f71674, speed=1 '\001') at ../../gcc/gcc/tree-ssa-loop-ivopts.c:3243 #6 0x08497e15 in force_var_cost (data=0xbfffe458, expr=0xb7f71674, depends_on=0xbfffe35c) at ../../gcc/gcc/tree-ssa-loop-ivopts.c:3360 #7 0x0849da6c in determine_use_iv_cost (data=0xbfffe458, use=0x887a1c8, cand=0x887a1f0) at ../../gcc/gcc/tree-ssa-loop-ivopts.c:3873 #8 0x0849dbca in determine_use_iv_costs (data=0xbfffe458) at ../../gcc/gcc/tree-ssa-loop-ivopts.c:3960 #9 0x084a0de1 in tree_ssa_iv_optimize () at ../../gcc/gcc/tree-ssa-loop-ivopts.c:5549 #10 0x084ad965 in tree_ssa_loop_ivopts () at ../../gcc/gcc/tree-ssa-loop.c:667 #11 0x0830363f in execute_one_pass (pass=0x8802240) at ../../gcc/gcc/passes.c:1279 #12 0x083038ac in execute_pass_list (pass=0x8802240) at ../../gcc/gcc/passes.c:1328 #13 0x083038bf in execute_pass_list (pass=0x8801e00) at ../../gcc/gcc/passes.c:1329 #14 0x083038bf in execute_pass_list (pass=0x8801680) at ../../gcc/gcc/passes.c:1329 #15 0x084215f0 in tree_rest_of_compilation (fndecl=0xb7f5e600) at ../../gcc/gcc/tree-optimize.c:418 #16 0x0858ef37 in cgraph_expand_function (node=0xb7f5e680) at ../../gcc/gcc/cgraphunit.c:1038 #17 0x08590d6f in cgraph_optimize () at ../../gcc/gcc/cgraphunit.c:1097 #18 0x0805eb8b in c_write_global_declarations () at ../../gcc/gcc/c-decl.c:8074 #19 0x083cbdf6 in toplev_main (argc=16, argv=0xbfffe714) at ../../gcc/gcc/toplev.c:979 #20 0x080d6722 in main (argc=131140, argv=0x0) at ../../gcc/gcc/main.c:35