|
From: Florian K. <br...@ac...> - 2013-02-02 15:46:41
|
On 02/01/2013 05:52 PM, Greg Parker wrote:
>
> 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.)
>
>
Thanks for the pointers. Unfortunately, neither of the suggestions work.
With gcc 4.6.3 -O2 that is. Comparing two HRegs field by field will
actually generate worse code than before (where regno was only 24 bits
wide).
And using __builtin_memcmp will generate a call into memcmp. So we get
an unresolved reference as we don't link against glibc..
I tried a few other optimisation options -O3, -Os, but they didn't make
a difference.
Florian
|