[Cbe-oss-dev] SPU-GCC optimzation problem

Hiroyuki Machida Hiroyuki.Mach at gmail.com
Tue Mar 11 20:10:09 EST 2008


Hi,

I got a problem with SPU-GCC in IBM Cell SDK 3.0.
I could not reproduce this with SPU-GCC in  older Cell
SDK 2.1 or 2.0. I attached details, below.


Hiroyuki.

---

* Summary

  The spu-gcc generates incorrect code for spu_rlmaskqwbyte intrinsic
  when:

  -- compiled with "-O1" or higher optimization level and

  -- the second argument is a constant (immediate) value and

  -- 1 <= (the second argument) mod 32 <= 16

* Version

  IBM Cell SDK 3.0 spu-gcc, spu-g++

  IBM Cell SDK 2.1 or earlier don't have this problem.

* Sample code

---
#include <spu_intrinsics.h>

vector unsigned int source = { 0x11111111, 0x22222222, 0x33333333,
0x44444444, };

int main(int argc, char **argv)
{
  vector unsigned int result;

  result = spu_rlmaskqwbyte(source, -17);

  /* all elements should be zero. */
  printf("0x%08x 0x%08x 0x%08x 0x%08x, \n",
spu_extract(result, 0),
spu_extract(result, 1),
spu_extract(result, 2),
spu_extract(result, 3));

  return 0;
}
---

* Additional information

  It seems that when optimization is enabled, the second argument is
  normalized into -15 to 0.

---
main:
        ila     $3,.LC0
        hbrr    .L3,printf
        lqr     $2,source
        stqd    $lr,16($sp)
        stqd    $sp,-32($sp)
        ai      $sp,$sp,-32
        nop     127
        rotqmbyi        $7,$2,-1 # <==========
        ori     $4,$7,0
        rotqbyi $5,$7,(1*4+0)%16
        rotqbyi $6,$7,(2*4+0)%16
        rotqbyi $7,$7,(3*4+0)%16
        nop     127
.L3:
        brsl    $lr,printf
        ai      $sp,$sp,32
        fsmbi   $3,0
        lqd     $lr,16($sp)
        bi      $lr
---



More information about the cbe-oss-dev mailing list