On Wed, 2020-06-10 at 10:46 -0500, will schmidt wrote:

<snip>
> > On Fri, 2020-06-05 at 16:28 -0500, Segher Boessenkool wrote:
> > > > +;; Return 1 if op is a 32-bit constant signed integer
> > > > +(define_predicate "s32bit_cint_operand"
> > > > +  (and (match_code "const_int")
> > > > +       (match_test "INTVAL (op) >= -2147483648
> > > > +          && INTVAL (op) <= 2147483647")))
> > > 
> > > There probably is a nicer way to write this than with big decimal
> > > numbers.  (I'll not suggest one here because I'll just make a
> > > fool
> > > of
> > > myself with overflow or signed/unsigned etc. :-) )
> > > 
> > > > +;; Return 1 if op is a constant 32-bit signed or unsigned
> > > > integer
> > > > +(define_predicate "c32bit_cint_operand"
> > > > +  (and (match_code "const_int")
> > > > +       (match_test "((INTVAL (op) >> 32) == 0)")))
> > 
> > The more I look at the above two they really are the
> > same.  Basically,
> > it boils down to ... can the value signed or unsigned fit in 32-
> > bits
> > or
> > not?  It seems like both of the above just need to test if the
> > INTVAL
> > (op) has any bits above bits 0:31 set.  So seems like (INTVAL (op)
> > >>
> > 32) == 0) should be sufficient for both predicates, i.e. replace
> > the
> > two with a single generic predicate "cint_32bit_operand".  
> > 
> > For starters, I tried changing the definition for
> > s32bit_cint_operand
> > to:
> > 
> > ; Return 1 if op is a 32-bit constant signed
> > integer                           
> > (define_predicate
> > "s32bit_cint_operand"                                         
> >   (and (match_code
> > "const_int")                                                 
> >        (match_test "((INTVAL (op) >> 32) == 0)")))
> 
> 
> Compare that to the other predicates (config/rs6000/predicates.md)
> 
> Those have explicit checks against both ends of the valid range of
> values.   i.e.
> 
> ;; Return 1 if op is a signed 5-bit constant integer.
> (define_predicate "s5bit_cint_operand"
>   (and (match_code "const_int")
>        (match_test "INTVAL (op) >= -16 && INTVAL (op) <= 15")))

Well, that is what I did originally.  But if you see your comment
above, "There probably is a nicer way to write this than with big
decimal numbers." so I was trying to figure out how to do it without
using big numbers.  I seemed like shifting the value right 32 bits and
checking if the result was zero would tell us that op fits in 32-bits
but it doesn't seem to work.  So, now I have conflicting feedback.  :-)

                      Carl 

Reply via email to