OpenCores
Issue List
Toolchain Terinary Operator Bug #157
Closed tsuckow opened this issue over 13 years ago
tsuckow commented over 13 years ago

The Terinary Operator does not generate conditional logic as expected. "If" works as expected.

Using GCC 4.5.1-or32-1.0rc4

Testcase: http://www.wuala.com/Deathbob/Files/OR32/Toolchain_T_OP_Error.zip/

Regards, Thomas

jeremybennett commented over 13 years ago
<p> I can't reproduce the problem. I stripped down your test program as follows: </p> <pre> #include <stdint.h> #include <unistd.h> #include <stdio.h>

volatile uint32_t const SDRAM_GOOD = (uint32_t const)0x01000000; volatile uint32_t const SDRAM_BAD = (uint32_t const)0x02000000;

int main (int argc, char *argv []) { unsigned long i; unsigned long j; unsigned long bob = 0xdeadbeef;

/ This should work / for(i = 0; i < 480; ++i) { for(j = 0; j < 800; ++j) { if(i == 0) { SDRAM_GOODi*800+j = 0x00FFFFFF; } else { SDRAM_GOODi*800+j = (uint8_t)(j+bob+i); } } }

/ This does not work / for(i = 0; i < 480; ++i) { for(j = 0; j < 800; ++j) { SDRAM_BADi*800+j = (i == 0)?0x00FFFFFF:((uint8_t)(j+bob+i)); } }

/ Compare the two / for(i = 0; i < 480; ++i) { for(j = 0; j < 800; ++j) { if (SDRAM_GOODi*800+j != SDRAM_BADi*800+j) { printf ("SDRAM_GOOD%6d = 0x%08x, SDRAM_BAD%6d = 0x%08x\n", i800+j, SDRAM_GOOD[i800+j], i800+j, SDRAM_BAD[i800+j]); } } } }

</pre> <p> I compiled this with </p> <pre> or32-elf-gcc test.c -o test </pre> <p> And ran it with </p> <pre> or32-elf-sim --memory=64M test </pre> <p> No mismatches were reported. I should be surprised if GCC were generating defective code for ternary operators - these are fairly extensively tested in regression. </p> <p> Can you provide more details to help trace this problem. </p> <p> Jeremy </p> <p> -- <br /> Tel: +44 (1590) 610184<br /> Cell: +44 (7970) 676050<br /> SkypeID: jeremybennett<br /> Email: <a href="mailto:jeremy.bennett@embecosm.com">jeremy.bennett@embecosm.com</a><br /> Web: <a href="http://www.embecosm.com">www.embecosm.com</a> </p>
jeremybennett commented over 13 years ago
<p> The above listing got its &lt; and &gt; symbols mangled. The included files were stdint.h, unistd.h and stdio.h. </p> <p> Jeremy </p>
jeremybennett was assigned over 13 years ago
jeremybennett commented over 13 years ago
<p> Transferred to OpenRISC bugzilla (<a href="http://bugzilla.opencores.org/show_bug.cgi?id=36">Bug 36</a>). </p> <p> Marking closed in this bugtracker. </p>
jeremybennett closed this over 13 years ago

Assignee
jeremybennett
Labels
Bug