[patch 1/2] AMD bdver2 processors - BMI
Quentin Neill
quentin.neill.gnu@gmail.com
Tue Nov 2 19:52:00 GMT 2010
On Tue, Nov 2, 2010 at 10:53 AM, Richard Henderson <rth@redhat.com> wrote:
> On 11/02/2010 05:27 AM, Quentin Neill wrote:
>> Actually BSF indexes the lowest set bit, TZCNT counts zeros, so if I'm
>> thinking clearly BSF(X)==TZCNT(X)+1
>
> Nope. Looking carefully the differences are:
>
> BSF TZCNT
> Result for 0 Undefined Operand-Width
> ZF Set iff 0 input Set iff 0 output
> CF Undefined Set iff 0 input
>
> otherwise the actual value result is identical.
Thanks, I misread the BSF definition, thinking it was indexed off bit
1. "Looking carefully" is the key :)
>>> #define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) ...[snip]...
>> I take it his goes in defaults.h? How do I test this?
> This goes in i386.h. Test this by seeing that __builtin_ctz
> with a constant operand 0 gets folded properly.
Okay, thanks.
Any hints on what test case this would go in?
> Note that
> there's a CLZ_DEFINED_VALUE_AT_ZERO as well, which would be
> used for the LZCNT instruction.
To be clear, this needs to be defined and added to i386.h as well.
I don't see where any tests exercise the existIng LZCNT insn yet, so
I'll add those too.
Going back to one of last week's replies...
On Fri, Oct 22, 2010 at 3:59 PM, Richard Henderson <rth@redhat.com> wrote:
> (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>")])
One more question:
The line that said
(set (attr "prefix_rep" (symbol_ref "TARGET_BMI"))
ended up being
(set (attr "prefix_rep") (symbol_ref "TARGET_BMI"))
but my question is how is the "prefix_rep" attribute used?
--
Quentin
More information about the Gcc-patches
mailing list