https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64689

            Bug ID: 64689
           Summary: tree-vectorize generates wrong code with inlined
                    function - minimum working example included
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: philipp.gschwandtner at uibk dot ac.at

Created attachment 34500
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34500&action=edit
minimum working example

The tree vectorizer in gcc 4.7-4.9 appears to generate semantically incorrect
code for the particular case clarified in the attached minimum working example.
gcc 4.6.3 does not show this issue. In gcc 4.7.3 only one of the checks fails,
in gcc 4.8.3 and 4.9.2 both of them fail (as these versions also seem to
recognize case A as vectorizable).

Testing was performed on an Intel Xeon E5-2699 v3 Haswell CPU running a
3.10.0-123.13.1.el7.x86_64 Linux kernel.

Compile with:

gcc test.c -o test -O3 -std=c99 -pedantic -Wall -Wextra -fwrapv
-fno-strict-aliasing

Expected output (equals gcc 4.6.3 output):

Checking case A:
EQUAL!
Checking case B:
EQUAL!

Actual output (for gcc 4.8.3 and 4.9.2):

Checking case A:
NOT EQUAL!
C1:
   -2     0i,    -2     0i,    -2     0i,    -2     0i, 
   -2     0i,    -2     0i,    -2     0i,    -2     0i, 
   -2     0i,    -2     0i,    -2     0i,    -2     0i, 
   -2     0i,    -2     0i,    -2     0i,    -2     0i, 
C2:
   -1     0i,    -1     0i,    -1     0i,    -1     0i, 
   -1     0i,    -1     0i,    -1     0i,    -1     0i, 
   -1     0i,    -1     0i,    -1     0i,    -1     0i, 
   -1     0i,    -1     0i,    -1     0i,    -1     0i, 
Checking case B:
NOT EQUAL!
C1:
   -2     0i,    -2     0i,    -2     0i,    -2     0i, 
   -2     0i,    -2     0i,    -2     0i,    -2     0i, 
   -2     0i,    -2     0i,    -2     0i,    -2     0i, 
   -2     0i,    -2     0i,    -2     0i,    -2     0i, 
C2:
   -1     0i,    -1     0i,    -1     0i,    -1     0i, 
   -1     0i,    -1     0i,    -1     0i,    -1     0i, 
   -1     0i,    -1     0i,    -1     0i,    -1     0i, 
   -1     0i,    -1     0i,    -1     0i,    -1     0i, 

Above output is produced when compiled with gcc 4.9.2 and 4.8.3. For gcc 4.7.3
the check for case A succeeds while the check for case B still fails.

Reply via email to