Issue Details (XML | Word | Printable)

Key: PCC-338
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Anders Magnusson
Reporter: Iain Hibbert
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.

64-bit assign/compare losing value

Created: 29/Apr/11 09:27 PM   Updated: 02/May/11 05:04 PM
Component/s: C frontend
Affects Version/s: None
Fix Version/s: None

Environment: NetBSD/i386

 Description  « Hide
the following example program

#include <stdio.h>

main(int ac, char *av[])
        long long cnt = 0;

        printf("cnt %lld\n", cnt);
        if ((cnt <= 0) && ((cnt = 32733) < 0))
                return 0;

        printf("cnt %lld\n", cnt);
        return 0;

when compiled with -Wc,-xtemps will produce the following output

cnt 0
cnt 0

as it has lost the value of cnt during the compare..

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Iain Hibbert added a comment - 29/Apr/11 09:30 PM
additionally, I found this in NetBSD pax when reading a tar file failed.. I don't recall if it
worked before PCC-289 was fixed (which also came from NetBSD pax but when creating
a tar file failed) - the construct is very similar though, I'm guessing related

Anders Magnusson added a comment - 30/Apr/11 10:29 AM - edited
No, this is not related to 289, except from the fact that it is the third(!) bug in the register allocator in a week; this time in the graph coloring code.
There is an inconvenience here also that triggers this bug: There can be recommendation of colors for nodes to avoid register-register moves, but the recommendation do not give the best register. If it had worked, this bug would never have been seen.
Bug analyzed more: it occurs when there is an assignment to a register class with concatenated registers, the result is needed for something, the move between node temp and dest register is removed in Freeze() and the registers got overlapping registers in coloring.
The correct way to solve this is to endure that there is no temporary register in an assignment if the destination is a register.

Anders Magnusson added a comment - 02/May/11 05:04 PM
Should be fixed now. This was a challenging bug, thanks!