<< Back to previous view

[PCC-384] Bug with bitshifting operation Created: 23/Dec/11  Updated: 24/Dec/11

Status: Resolved
Project: pcc
Component/s: i386 target
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: D C Gosnell Assignee: Anders Magnusson
Resolution: Fixed Votes: 0
Environment: Linux 2.6.31-21-generic-pae #59-Ubuntu SMP Wed Mar 24 08:47:55 UTC 2010 i686 GNU/Linux
pcc compiled with gcc 4.4.1

File Attachments: File pccbug.c    

The following program produces the output "IT'S 2", when I would expect "IT'S 0"

#include <stdio.h>

int main()
    int g = 0, b = 0, s = 0;
    long l = (g/2) | ((b/2)<<s);
    printf("IT'S %lx\n", l);

Comment by D C Gosnell [ 23/Dec/11 03:51 PM ]
I should have added the pcc version, which is :-

pcc 1.1.0.DEVEL 20111214 for i686-pc-linux-gnu
Comment by Anders Magnusson [ 23/Dec/11 05:37 PM ]
Yetch, this simple code fails on amd64 also. Hm...
Comment by Anders Magnusson [ 24/Dec/11 12:03 PM ]
Fixed now, thanks for a good bug report!
The problem was that when an instruction with special needs (like left shift on i386 which requires the shift count in cl) but no explicit result register the register assigned by the register allocator was ignored.
Generated at Fri Apr 20 22:09:20 CEST 2018 using JIRA Enterprise Edition, Version: 3.13.1-#333.