From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kevin Ryde To: gcc-gnats@gcc.gnu.org Subject: c/4214: powerpc64: wrong code from optimized mask and shift Date: Mon, 03 Sep 2001 16:46:00 -0000 Message-id: <87bskrdeta.fsf@zip.com.au> X-SW-Source: 2001-09/msg00044.html List-Id: >Number: 4214 >Category: c >Synopsis: powerpc64: wrong code from optimized mask and shift >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Mon Sep 03 16:46:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: >Release: 3.0 >Organization: >Environment: System: AIX panther 3 4 000785504C00 host: powerpc-ibm-aix4.3.2.0 build: powerpc-ibm-aix4.3.2.0 target: powerpc-ibm-aix4.3.2.0 configured with: ../gcc-3.0/configure >Description: A certain mask and shift combination produces a wrong answer when compiled with optimization. >How-To-Repeat: A program foo.c, int n = 3; int main (void) { printf ("%d\n", (n & 2) << 1); return 0; } when compiled with gcc -O -maix64 -mpowerpc64 foo.c and run just as "./a.out", prints 6 whereas I think it should print 4 (and which it does if compiled without the -O). For what it's worth, it seems this only happens under "-maix64 -mpowerpc64", not in 32-bit mode. >Fix: >Release-Note: >Audit-Trail: >Unformatted: