2016-08-08 11:48 PM
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 static0
or1
fill bits), cf. . 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. #vle #gcc2016-08-09 02:10 AM
Hello robert ,
Yes , i have reproduced the issue.i have submitted a critical ER in our side.Could you compile temporarly in -O0 ?i am checking the issue. Best regards Erwan2016-08-09 07:07 AM
Hello Robert ,
e_subfic can not work on a u16 it is clearly an error coming from freegcc. You can use this code example to force a non optimization for this case :__attribute__((optimize(
''-O0''
))) uint8_t illegal_value_test(uint16_t arg0) {
if
(arg0 <= 0x7FF)
return
TRUE;
else
return
FALSE;
}
Best Regards
Erwan