This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch 1/2] AMD bdver2 processors - BMI


On Thu, Oct 28, 2010 at 10:45 PM, Richard Henderson <rth@redhat.com> wrote:
> On 10/28/2010 02:37 PM, Quentin Neill wrote:
>> +(define_insn "bmi_tzcnt_<mode>"
>> + ?[(set (match_operand:SWI248 0 "register_operand" "=r")
>> + ? ? (unspec:SWI248 [(match_operand:SWI248 1 "nonimmediate_operand" "rm")]
>> + ? ? ? ? ? ? UNSPEC_TZCNT))
>> + ? (clobber (reg:CC FLAGS_REG))]
>
> Um, why didn't you modify the CTZ named pattern as we discussed?
>
>> +__blsi_u64 (unsigned long long __X)
>> +{
>> + ?unsigned long long tmp = (__X) & (__X * -1);
>
> Use unary negate instead of mult by -1.
>
> r~

Hi Richard,

Thanks for the feedback on the blsi intrinsic above.

The reason I didn't modify CTZ is ... I got stuck with questions, see below.



On Fri, Oct 22, 2010 at 3:59 PM, Richard Henderson <rth@redhat.com> wrote:
> On 10/22/2010 12:32 PM, Quentin Neill wrote:
>
> The difference between bsf and tzcnt is essentially in the
> handling of the flags and zero input, correct?

Actually BSF indexes the lowest set bit, TZCNT counts zeros, so if I'm
thinking clearly BSF(X)==TZCNT(X)+1

So I'm wondering if these two insns should be combined after all?


> (define_insn "ctz<mode>2"
>  [(set (match_operand:SWI48 0 "register_operand" "=r")
>        (ctz:SWI48 (match_operand:SWI48 1 "nonimmediate_operand" "rm")))
>   (clobber (reg:CC FLAGS_REG))]
>  ""
> {
>  if (TARGET_BMI)
>    return "tzcnt{<imodesuffix>}\t{%1, %0|%0, %1}";
>  else
>    return "bsf{<imodesuffix>}\t{%1, %0|%0, %1}";
> }
>  [(set_attr "type" "alu1")
>   (set_attr "prefix_0f" "1")
>   (set (attr "prefix_rep" (symbol_ref "TARGET_BMI"))
>   (set_attr "mode" "<MODE>")])
>
> /* The value at zero is only defined for the BMI instruction
>   TZCNT, not the BSF insn in the original isa.  */
> #define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) \
>  ((VALUE) = GET_MODE_BITSIZE (MODE), TARGET_BMI)

I take it his goes in defaults.h?  How do I test this?

> Note that this has already been done for lzcnt as present
> in the ABM extension.

I believe the LZCNT instruction is not a part of the BMI extension,
I've removed it from the list of mnemonics.


-- 
Quentin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]