|
From: Greg P. <gp...@ap...> - 2013-02-01 22:52:13
|
On Feb 1, 2013, at 12:26 PM, Florian Krohm <br...@ac...> wrote:
> I looked at two implementation choices:
>
> 1) make HReg a proper struct
>
> typedef struct {
> UInt regno : 24;
> HRegClass class : 4;
> Bool virtual : 1;
> } HReg;
>
> 2) Wrap the current register encoding into a struct:
>
> typedef struct {
> UInt reg;
> } HReg;
>
> Because comparison gets used a lot in the register allocator I chose #2.
> Patch attached and regtested on x86-x64, s390, and ppc with no new
> regressions.
You can optimize #1.
First, make sure the bitfield spans all 32 bits. (I'd also recommend not using the C++ keywords "class" and "virtual" in the names.)
typedef struct {
UInt regno : 27;
HRegClass regclass : 4;
Bool isvirtual : 1;
} HReg;
Second, write the comparison function with memcmp(). Your compiler optimizer should be able to transform the call into a single compare.
(Curiously, `clang -Os` was unable to optimize the field-by-field comparison, even after expanding the struct to 32 bits.)
--
Greg Parker gp...@ap... Runtime Wrangler
|