Re: Wider modes for partial int modes
On 06/09/2012 01:58 AM, Mike Stump wrote: On Jun 8, 2012, at 4:11 PM, Mike Stump wrote: On Apr 17, 2012, at 2:08 PM, Bernd Schmidt wrote: This patch enables GET_MODE_WIDER_MODE for MODE_PARTIAL_INT (by setting the wider mode to the one the partial mode is based on), which is useful for the port I'm working on: I can avoid defining operations on the partial modes. I think this breaks my port, in emit-rtl.c: B for (mode = GET_CLASS_NARROWEST_MODE (MODE_PARTIAL_INT); mode != VOIDmode; mode = GET_MODE_WIDER_MODE (mode)) = const_tiny_rtx[i][(int) mode] = GEN_INT (i); Doesn't work, as that does expects to step through all partial int modes. The problem is, we went from P1QI - P1SI, and now we go from P1QI to QI. The problem is this, we never initialize P1SI anymore, and later, when initializing vector constants, things like V2P1SI dies, as P1SI was never built: So, maybe we want to go through all modes, and just ask, are you a MODE_PARTIAL_INT, and initialize them that way? Thoughts? The below patch allows my port to at least initialize once more... Thoughts? Ok? Looks good to me. Bernd
Re: Wider modes for partial int modes
On Jun 8, 2012, at 4:11 PM, Mike Stump wrote: On Apr 17, 2012, at 2:08 PM, Bernd Schmidt wrote: This patch enables GET_MODE_WIDER_MODE for MODE_PARTIAL_INT (by setting the wider mode to the one the partial mode is based on), which is useful for the port I'm working on: I can avoid defining operations on the partial modes. I think this breaks my port, in emit-rtl.c: B for (mode = GET_CLASS_NARROWEST_MODE (MODE_PARTIAL_INT); mode != VOIDmode; mode = GET_MODE_WIDER_MODE (mode)) = const_tiny_rtx[i][(int) mode] = GEN_INT (i); Doesn't work, as that does expects to step through all partial int modes. The problem is, we went from P1QI - P1SI, and now we go from P1QI to QI. The problem is this, we never initialize P1SI anymore, and later, when initializing vector constants, things like V2P1SI dies, as P1SI was never built: /* We need to call this function after we set the scalar const_tiny_rtx entries. */ gcc_assert (const_tiny_rtx[constant][(int) inner]); So, maybe we want to go through all modes, and just ask, are you a MODE_PARTIAL_INT, and initialize them that way? Thoughts? The below patch allows my port to at least initialize once more... Thoughts? Ok? diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index af804df..8ff74c8 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -5704,9 +5704,9 @@ init_emit_once (void) mode = GET_MODE_WIDER_MODE (mode)) const_tiny_rtx[i][(int) mode] = GEN_INT (i); - for (mode = GET_CLASS_NARROWEST_MODE (MODE_PARTIAL_INT); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + for (mode = MIN_MODE_PARTIAL_INT; + mode = MAX_MODE_PARTIAL_INT; + mode = (enum machine_mode)((int)(mode) + 1)) const_tiny_rtx[i][(int) mode] = GEN_INT (i); } @@ -5717,9 +5717,9 @@ init_emit_once (void) mode = GET_MODE_WIDER_MODE (mode)) const_tiny_rtx[3][(int) mode] = constm1_rtx; - for (mode = GET_CLASS_NARROWEST_MODE (MODE_PARTIAL_INT); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + for (mode = MIN_MODE_PARTIAL_INT; + mode = MAX_MODE_PARTIAL_INT; + mode = (enum machine_mode)((int)(mode) + 1)) const_tiny_rtx[3][(int) mode] = constm1_rtx; for (mode = GET_CLASS_NARROWEST_MODE (MODE_COMPLEX_INT);
Re: Wider modes for partial int modes
On 04/17/2012 04:08 PM, Bernd Schmidt wrote: * machmode.h (CLASS_HAS_WIDER_MODES_P): True for MODE_PARTIAL_INT. * expr.c (convert_move): Honor unsignedp when extending partial int modes. * genmodes.c (power_of_two_p, regular_mode, make_complex_modes, emit_mode_wider): Revert Spider hacks. (complete_mode): Don't clear component field of partial int modes. (emit_mode_inner): Don't emit it however. (calc_wider_mode): Partial int modes widen to their component. Ok. r~
Wider modes for partial int modes
This patch enables GET_MODE_WIDER_MODE for MODE_PARTIAL_INT (by setting the wider mode to the one the partial mode is based on), which is useful for the port I'm working on: I can avoid defining operations on the partial modes. Also, convert_modes is changed so that unsignedp is taken into account when widening partial modes. I've tested this on m32c-elf as well as on my port, and bootstrapped on i686-linux. Ok? Bernd * machmode.h (CLASS_HAS_WIDER_MODES_P): True for MODE_PARTIAL_INT. * expr.c (convert_move): Honor unsignedp when extending partial int modes. * genmodes.c (power_of_two_p, regular_mode, make_complex_modes, emit_mode_wider): Revert Spider hacks. (complete_mode): Don't clear component field of partial int modes. (emit_mode_inner): Don't emit it however. (calc_wider_mode): Partial int modes widen to their component. Index: machmode.h === --- machmode.h (revision 186270) +++ machmode.h (working copy) @@ -166,6 +166,7 @@ extern const unsigned char mode_class[NU /* Nonzero if CLASS modes can be widened. */ #define CLASS_HAS_WIDER_MODES_P(CLASS) \ (CLASS == MODE_INT \ + || CLASS == MODE_PARTIAL_INT\ || CLASS == MODE_FLOAT \ || CLASS == MODE_DECIMAL_FLOAT \ || CLASS == MODE_COMPLEX_FLOAT \ Index: expr.c === --- expr.c (revision 186270) +++ expr.c (working copy) @@ -438,21 +438,20 @@ convert_move (rtx to, rtx from, int unsi rtx new_from; enum machine_mode full_mode = smallest_mode_for_size (GET_MODE_BITSIZE (from_mode), MODE_INT); + convert_optab ctab = unsignedp ? zext_optab : sext_optab; + enum insn_code icode; - gcc_assert (convert_optab_handler (sext_optab, full_mode, from_mode) - != CODE_FOR_nothing); + icode = convert_optab_handler (ctab, full_mode, from_mode); + gcc_assert (icode != CODE_FOR_nothing); if (to_mode == full_mode) { - emit_unop_insn (convert_optab_handler (sext_optab, full_mode, -from_mode), - to, from, UNKNOWN); + emit_unop_insn (icode, to, from, UNKNOWN); return; } new_from = gen_reg_rtx (full_mode); - emit_unop_insn (convert_optab_handler (sext_optab, full_mode, from_mode), - new_from, from, UNKNOWN); + emit_unop_insn (icode, new_from, from, UNKNOWN); /* else proceed to integer conversions below. */ from_mode = full_mode; Index: genmodes.c === --- genmodes.c (revision 186270) +++ genmodes.c (working copy) @@ -360,7 +360,6 @@ complete_mode (struct mode_data *m) m-bytesize = m-component-bytesize; m-ncomponents = 1; - m-component = 0; /* ??? preserve this */ break; case MODE_COMPLEX_INT: @@ -823,7 +822,13 @@ calc_wider_mode (void) sortbuf[i] = 0; for (j = 0; j i; j++) - sortbuf[j]-next = sortbuf[j]-wider = sortbuf[j + 1]; + { + sortbuf[j]-next = sortbuf[j + 1]; + if (c == MODE_PARTIAL_INT) + sortbuf[j]-wider = sortbuf[j]-component; + else + sortbuf[j]-wider = sortbuf[j]-next; + } modes[c] = sortbuf[0]; } @@ -1120,7 +1125,8 @@ emit_mode_inner (void) for_all_modes (c, m) tagged_printf (%smode, - m-component ? m-component-name : void_mode-name, + c != MODE_PARTIAL_INT m-component + ? m-component-name : void_mode-name, m-name); print_closer ();