Hi Sgan,
<div class='quotetop'>QUOTE </div>
--- Quote Start ---
With this code, you can be sure you get wrong results...[/b]
--- Quote End ---
You are correct. Which is why I recommend not using the defective builtin.
<div class='quotetop'>QUOTE </div>
--- Quote Start ---
Thank you very much for finding this issue in the compiler. You are correct that there is a bug here, __builtin_ldbio() should be translating to a ldbio instruction, not a ldhio. This issue will be fixed for the next release of the compiler. If this is causing you a particular issue, I recommend either using __builtin_ldbuio() and sign extending it, or using extended assembly statements.[/b]
--- Quote End ---
Let me elaborate on the above. What I recommend your code look like is this:
int testsub1(void) {
char x = __builtin_ldbuio ((void *)0x1000);
return (int)x; // sign extend x
}
Or using asm statements:
int testsub2(void) {
int x;
asm ("ldbio %, 0(%)" : "=r" (x) : "r" (0x1000));
return x;
}