On 08/28/2013 10:45 AM, Kirill Yukhin wrote:
> Hello Richard,
> 
> On 27 Aug 13:07, Richard Henderson wrote:
>> On 08/27/2013 11:11 AM, Kirill Yukhin wrote:
>>>>> What happened to the bmi andn alternative we discussed?
>>> BMI only supported for 4- and 8- byte integers, while
>>> kandw - for HI/QI
>>>
>>
>> We're talking about values in registers.  Ignoring the high bits of the andn
>> result still produces the correct results.
> 
> I've updated patch, adding BMI alternative and clobber of flags:
> +(define_insn "kandn<mode>"
> +  [(set (match_operand:SWI12 0 "register_operand" "=r,&r,!k")
> +       (and:SWI12
> +         (not:SWI12
> +           (match_operand:SWI12 1 "register_operand" "r,0,k"))
> +         (match_operand:SWI12 2 "register_operand" "r,r,k")))
> +   (clobber (reg:CC FLAGS_REG))]
> +  "TARGET_AVX512F"
> +  "@
> +   andn\t{%k2, %k1, %k0|%k0, %k1, %k2}
> +   #
> +   kandnw\t{%2, %1, %0|%0, %1, %2}"
> +  [(set_attr "type" "bitmanip,*,msklog")
> +   (set_attr "prefix" "*,*,vex")
> +   (set_attr "btver2_decode" "direct,*,*")
> +   (set_attr "mode" "<MODE>")])
> 
> However I am not fully understand why do we need this.
> `kandn' is different from BMI `andn' in clobbering of flags reg.
> So, having such a pattern we'll make compiler think that `kandn'
> clobber, which seems to me like opportunity to misoptimization as
> far as `kandn' doesn't clobber.

This is no different than ANY OTHER use of the mask logical ops.

When combine puts the AND and the NOT together, we don't know what registers we
want the data in.  If we do not supply the general register alternative, with
the clobber, then we will be FORCED to implement the operation in the mask
registers, even if this operation had nothing to do with actual vector masks.
And it ought to come as no surprise that X & ~Y is a fairly common operation.

I suppose a real question here in how this is written: Does TARGET_AVX512F
imply TARGET_BMI?  If so, then we can eliminate the second alternative.  If
not, then you are missing an set_attr isa to restrict the first alternative.



r~

Reply via email to