radeonsi: use shifts for sign extension
authorGrazvydas Ignotas <notasas@gmail.com>
Sat, 16 Jun 2018 18:56:13 +0000 (21:56 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Thu, 21 Jun 2018 09:17:34 +0000 (12:17 +0300)
Avoids a branch and reduces code size a tiny bit:
    text   data     bss      dec    hex filename
10804563 398653 2070368 13273584 ca89f0 /tmp/radeonsi_dri.so.old
10804499 398653 2070368 13273520 ca89b0 /tmp/radeonsi_dri.so

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/radeonsi/si_descriptors.c

index d3da8a470a460bd76680b0855d52382e720378ad..9de0112878e84c5fabbef2e5a2a8cd3e2b6f471a 100644 (file)
@@ -100,8 +100,8 @@ static uint64_t si_desc_extract_buffer_address(const uint32_t *desc)
                      ((uint64_t)G_008F04_BASE_ADDRESS_HI(desc[1]) << 32);
 
        /* Sign-extend the 48-bit address. */
-       if (va & (1ull << 47))
-               va |= 0xffffull << 48;
+       va <<= 16;
+       va = (int64_t)va >> 16;
        return va;
 }