On Tue, 2020-06-09 at 17:01 -0700, Carl Love wrote: > Segher: > > So I have been looking at the predicate definitions that I had > created. > > 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"))) > > Unfortunately it doesn't seem to work for > > (define_insn > "xxspltiw_v4si" > [(set (match_operand:V4SI 0 "register_operand" > "=wa") > (unspec:V4SI [(match_operand:SI 1 "s32bit_cint_operand" > "n")] > UNSPEC_XXSPLTIW))] > > "TARGET_FUTURE" > > "xxspltiw > %x0,%1" > [(set_attr "type" "vecsimple")]) > > I get unrecongized insn. It seems like (INTVAL (op) >> 32) == 0) > should be true for any 32-bit integer signed or unsigned??? > > Any thoughts as to why this doesn't work? > > > > > This does not work for negative 32-bit numbers? In GCC the LHS > > expression is -1 for those... Not sure what it is for the C++11 we > > now > > require, but in C11 it is implementation-defined, so not good > > either. > > > > > +;; Return 1 if op is a constant 32-bit floating point value > > > +(define_predicate "f32bit_const_operand" > > > + (match_code "const_double")) > > > > Either the predicate name is misleading (if you do allow all > > const_double values), or there should be some test for the alloed > > values > > here. > > The predicate is used to check for a 32-bit float constant. Looking > thru the code not sure if const_double is a 64-bit float? I don't > think > that is what I want. I want a 32-bit floating point value, > const_float, const_real? Don't see a a const_float or anything that > looks like that? Not having much luck to see where const_double gets > defined to see what other definitions there are. > > I am assuming at this point in the compilation process, the constant > that is passed has type info (signed int, unsigned int, float) > associated with it from the front end parsing of the source code. > > Carl >