Message ID | 20170105164651.GA6294@linux.vnet.ibm.com |
---|---|
State | New |
Headers | show |
On Thu, Jan 05, 2017 at 05:46:51PM +0100, Dominik Vogt wrote: > The attached patch deals with another type of zero_extend that is > not yet handled in change_zero_ext, i.e. (zero_extend > (pseudoreg)), without a "subreg" in between. What do you think? > (Mostly untested yet.) My main question is: where is this useful? Can you show some example please? Segher
On Wed, Jan 11, 2017 at 12:02:40PM -0600, Segher Boessenkool wrote: > On Thu, Jan 05, 2017 at 05:46:51PM +0100, Dominik Vogt wrote: > > The attached patch deals with another type of zero_extend that is > > not yet handled in change_zero_ext, i.e. (zero_extend > > (pseudoreg)), without a "subreg" in between. What do you think? > > (Mostly untested yet.) > > My main question is: where is this useful? Can you show some example > please? With this test program: int foo (int *b) { int i; int r; for (i = 0; i < 77; i++) { r |= b[0] > 0; r |= b[i] > 0; } return r; } before combine we have (insn 47 45 48 7 (set (reg:SI 104) (zero_extend:SI (reg:QI 103))) (insn 48 47 49 7 (parallel [ (set (reg/v:SI 88 [ r ]) (ior:SI (reg/v:SI 88 [ r ]) (reg:SI 104))) (clobber (reg:CC 33 %cc)) ]) combine tries (set (reg/v:SI 88 [ r ]) (ior:SI (zero_extend:SI (reg:QI 103)) (reg/v:SI 88 [ r ]))) With the patch it also tries (set (reg/v:SI 88 [ r ]) (ior:SI (and:SI (subreg:SI (reg:QI 103) 0) (const_int -1 [0xffffffffffffffff])) (reg/v:SI 88 [ r ]))) which is just one of the standard patterns for rosbg. Ciao Dominik ^_^ ^_^
Hi Dominik, Thanks for the example. ROSBG, what a weird instruction. On Thu, Jan 05, 2017 at 05:46:51PM +0100, Dominik Vogt wrote: > --- a/gcc/combine.c > +++ b/gcc/combine.c > @@ -11372,6 +11372,16 @@ change_zero_ext_src (subrtx_ptr_iterator *piter) > else if (GET_CODE (x) == ZERO_EXTEND > && SCALAR_INT_MODE_P (mode) > && REG_P (XEXP (x, 0)) > + && !HARD_REGISTER_P (XEXP (x, 0)) > + && GET_MODE_PRECISION (GET_MODE (XEXP (x, 0))) > + < GET_MODE_PRECISION (mode)) > + { > + /* (zero_extract (reg)) -> (and (subreg (reg) 0) (const_int)) */ s/zero_extract/zero_extend/ > * combine.c (change_zero_ext_src): Handle zero_extend without subreg. "Handle zero_extend of a pseudo."? Okay for trunk with that. Thanks for the patch, Segher
On Thu, Jan 12, 2017 at 11:02:36AM -0600, Segher Boessenkool wrote: > Hi Dominik, > > Thanks for the example. ROSBG, what a weird instruction. > > On Thu, Jan 05, 2017 at 05:46:51PM +0100, Dominik Vogt wrote: > > --- a/gcc/combine.c > > +++ b/gcc/combine.c > > @@ -11372,6 +11372,16 @@ change_zero_ext_src (subrtx_ptr_iterator *piter) > > else if (GET_CODE (x) == ZERO_EXTEND > > && SCALAR_INT_MODE_P (mode) > > && REG_P (XEXP (x, 0)) > > + && !HARD_REGISTER_P (XEXP (x, 0)) > > + && GET_MODE_PRECISION (GET_MODE (XEXP (x, 0))) > > + < GET_MODE_PRECISION (mode)) > > + { > > + /* (zero_extract (reg)) -> (and (subreg (reg) 0) (const_int)) */ > > s/zero_extract/zero_extend/ > > > * combine.c (change_zero_ext_src): Handle zero_extend without subreg. > > "Handle zero_extend of a pseudo."? k > Okay for trunk with that. It still needs testing. I'll do that in a while. Ciao Dominik ^_^ ^_^
On Thu, Jan 12, 2017 at 11:02:36AM -0600, Segher Boessenkool wrote: > Thanks for the example. ROSBG, what a weird instruction. And it's annoying too because it does the same as RISBG in some cases and can confuse "combine" to take a different branch that turns out to be a dead end. > On Thu, Jan 05, 2017 at 05:46:51PM +0100, Dominik Vogt wrote: > > --- a/gcc/combine.c > > +++ b/gcc/combine.c > > @@ -11372,6 +11372,16 @@ change_zero_ext_src (subrtx_ptr_iterator *piter) > > else if (GET_CODE (x) == ZERO_EXTEND > > && SCALAR_INT_MODE_P (mode) > > && REG_P (XEXP (x, 0)) > > + && !HARD_REGISTER_P (XEXP (x, 0)) > > + && GET_MODE_PRECISION (GET_MODE (XEXP (x, 0))) > > + < GET_MODE_PRECISION (mode)) > > + { > > + /* (zero_extract (reg)) -> (and (subreg (reg) 0) (const_int)) */ > > s/zero_extract/zero_extend/ > > > * combine.c (change_zero_ext_src): Handle zero_extend without subreg. > > "Handle zero_extend of a pseudo."? > > Okay for trunk with that. Thanks for the patch, The patch forgot to set "size" and generated invalid Rtl because of that. Fixed and tested, but I'd prefer to repost my growing stack of patches when gcc-7 is released. There are too many changes in "combine" and "simplify" that may depend on each other. Ciao Dominik ^_^ ^_^
diff --git a/gcc/combine.c b/gcc/combine.c index e77f203..b5131b8 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -11372,6 +11372,16 @@ change_zero_ext_src (subrtx_ptr_iterator *piter) else if (GET_CODE (x) == ZERO_EXTEND && SCALAR_INT_MODE_P (mode) && REG_P (XEXP (x, 0)) + && !HARD_REGISTER_P (XEXP (x, 0)) + && GET_MODE_PRECISION (GET_MODE (XEXP (x, 0))) + < GET_MODE_PRECISION (mode)) + { + /* (zero_extract (reg)) -> (and (subreg (reg) 0) (const_int)) */ + x = gen_lowpart_SUBREG (mode, XEXP (x, 0)); + } + else if (GET_CODE (x) == ZERO_EXTEND + && SCALAR_INT_MODE_P (mode) + && REG_P (XEXP (x, 0)) && HARD_REGISTER_P (XEXP (x, 0)) && can_change_dest_mode (XEXP (x, 0), 0, mode)) {