Issue Details (XML | Word | Printable)

Key: PCC-289
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.

long long bitshift fails with -xtemps

Created: 01/Apr/11 07:41 PM   Updated: 29/Apr/11 06:23 PM
Component/s: i386 target
Affects Version/s: None
Fix Version/s: None

Environment: NetBSD/i386

 Description  « Hide
The following short program

#include <stdio.h>

int main(int ac, char *av[])
        unsigned long long val = 0123;

        for (int i = 0; i < 12; i++) {
                if ((val >>= 3) == 0)

        printf("%s\n", val ? "fail" : "zero");
        return 0;

when compiled using -Wc,-xtemps will print "fail" which is wrong

when compiled without any optimisation flags it prints "zero" which is correct as there are less than 12 octal digits

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson added a comment - 28/Apr/11 10:03 PM
Hm, interesting, this is another bug in the register allocator :-) The statement "val = val << 3" matches a possible table entry where val can be modified directly, but the liveness of val is ended when it is read for shift and then started again at the assignment. In the time between it becames clobbered due to the other end of the shift (3) get moved to this register. Interesting :-)

Anders Magnusson added a comment - 29/Apr/11 06:23 PM
Fixed by disallowing left required reg to be used as right reg and vice versa.