Bug 45373 - V850 branches and compares are invalid
Summary: V850 branches and compares are invalid
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.4.4
: P3 critical
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2010-08-21 23:43 UTC by Alex Marshall
Modified: 2011-05-09 02:31 UTC (History)
2 users (show)

See Also:
Host: x86_64-linux-gnu
Target: v850-elf
Build: x86_64-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments
the .i file (102 bytes, text/plain)
2010-08-21 23:45 UTC, Alex Marshall
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Marshall 2010-08-21 23:43:00 UTC
My machine is running 64bit Ubuntu, and GCC was configured with this line:
/opt/v850/gcc-4.4.4/configure --target=v850-elf --enable-targets=all --prefix=/opt/v850 --disable-multilib --enable-languages=c --without-headers --disable-nls --disable-threads --disable-shared --disable-libmudflap --disable-libssp --disable-libgomp --disable-decimal-float --enable-checking=release
The build command used is: v850-elf-gcc -nostdlib -nostartfiles -nodefaultlibs -save-temps ctest.c -c -o ctest.v850.o
There were no warnings or other output

I built a bit of code containing a simple for loop that increments a number from 0 to 8, and the assembly generated uses BLE for branching if the condition is met. The proper instruction to generate would be BGE, since we want to run the body of the code while 7 >= iterator, whereas it currently checks if 7 <= iterator.
Comment 1 Alex Marshall 2010-08-21 23:45:00 UTC
Created attachment 21540 [details]
the .i file
Comment 2 Alex Marshall 2010-08-21 23:47:20 UTC
I tested both 4.4.4 and 4.4.0 and they both generate the wrong code.
Comment 3 Alex Marshall 2010-08-22 02:47:12 UTC
This actually appears to be the same problem when comparing in the other direction as well. If I change the source from i < 8 to i > 8, then it uses ``cmp 8, iter; bgt 0xf00'', which is also wrong, since we want 8 < iterator, not 8 > iterator.
Comment 4 Alex Marshall 2011-04-14 03:30:09 UTC
I have just come back to this, and it appears that the correct code was being generated in the first place. I must have misread the datasheet or something.
In any case, this is now resolved.
Comment 5 Alex Marshall 2011-05-09 01:22:27 UTC
Sorry for bumping this bug yet again, but it appears as if it really is generating incorrect code. After looking at several other code which has been verified to run, and reviewing the datasheet heavily, it appears GCC is truly generating incorrect code. For all branches, the direction of the compare is incorrect; e.g., BGE should be BLE, BNL should be BNH, BLT should be BGT.
Comment 6 Alex Marshall 2011-05-09 02:31:55 UTC
This bug appears to have been fixed somewhere between 4.4.4 and 4.5.3, so this bug can be closed.