AnsweredAssumed Answered

[BUG] Free GCC 4.9.2 illegal operand for VLE e_subfic instruction

Question asked by Robert.Abel on Aug 9, 2016
Latest reply on Aug 9, 2016 by Erwan Y
I just wanted to report a bug with the new free gcc 4.9.2. distributed in SPC5Studio 4. The compiler is apparently not aware of the special SCI8 format required by the e_subfic VLE instruction.

The following code example consistently exhibits the error for me:

1.uint8_t illegal_value_test(uint16_t arg0) {
2. 
3.    if (arg0 <= 0x7FF)
4.        return TRUE;
5.    else
6.        return FALSE;
7. 
8.}

The important part is the comparison with <= 0x7FF (or < 0x800, doesn't matter), which will output the following asm:

   5                    .section    .text.illegal_value_test,"axv",@progbits
   6                    .align 1
   7                    .p2align 4,,15
   8                    .globl illegal_value_test
   9                    .type   illegal_value_test, @function
  10                illegal_value_test:
  11                .LFB4:
  12                    .file 1 "main.c"
  13                    .loc 1 22 0
  14                    .cfi_startproc
  15                .LVL0:
  16                    .loc 1 29 0
  17 ???? 1863B000      e_subfic %r3,%r3,2047
****  Error: illegal immediate value
  18 ???? 70600000      e_li %r3,0
  19 ???? 7C631914      adde %r3,%r3,%r3
  20                .LVL1:
  21 ???? 0004          se_blr
  22                    .cfi_endproc
  23                .LFE4:
  24                    .size   illegal_value_test, .-illegal_value_test

Notice how the e_subfic instruction is supposed to encode 2047 (0x7FF), when it can only encode an optionally shifted uint8_t (and static 0 or 1 fill bits), cf. VLEPEM. The assembler rightly complains about this illegal operand (an older assembler actually says it's not a legal SCI8 immediate, whereas the new assembler will just say it's an illegal immediate. So the new assembler is less informative)

P.S. I've taken the liberty of directing Pierro Buratti to this thread as he's listed as the contact for the Free PowerPC VLE GCC 4.9.2. page in Eclipse Marketplace.

Outcomes