From Bugzilla Helper: User-Agent: Opera/8.50 (Windows NT 5.1; U; en) Description of problem: Using (or attempting to use) vector instructions generates incorrect code on ia64. In the sample program, every second element of the sum misses one of the operands. Version-Release number of selected component (if applicable): gcc version 3.4.3 20050227 (Red Hat 3.4.3-22.1) How reproducible: Always Steps to Reproduce: 1.gcc -O1 gcc_vector_ia64_bug.c 2../a.out 3. Actual Results: testing scalar version testing vector version dst[ 1] a: 1.020000 e: 2.030000 dst[ 3] a: 3.060000 e: 6.090000 dst[ 5] a: 5.100000 e: 10.150000 dst[ 7] a: 7.140000 e: 14.210000 dst[ 9] a: 9.180000 e: 18.270000 dst[ 11] a: 11.220000 e: 22.330000 dst[ 13] a: 13.260000 e: 26.389999 dst[ 15] a: 15.300000 e: 30.450001 Expected Results: testing scalar version testing vector version Additional info: Works on other tested architectures (ia32, x86_64)
Created attachment 120577 [details] C source
Created attachment 122387 [details] Patch that fixes the bug The bug is in the way we open-code the vector addition. When we see code such as: tmp0 += some_vector; we emit code that writes to the first element of tmp0 with a subreg. Since on IA64 two floats fit in a word, the subreg has the effect of clobbering the second element of the vector. Oops. The attached patch makes sure we do not use such a subreg as the output of the open-coded instruction if the output matches any of the inputs. This code is not present in mainline any more, as the open-coding was all moved to the tree level, so this patch is not going upstream unless people tell me it's a good idea to get it into upstream 3.4 or so.
This issue is on Red Hat Engineering's list of planned work items for the upcoming Red Hat Enterprise Linux 4.4 release. Engineering resources have been assigned and barring unforeseen circumstances, Red Hat intends to include this item in the 4.4 release.
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on the solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2006-0509.html