Bug 1429961

Summary: vec_vmul{e,o}u{b,h} AltiVec built-in functions broken on ppc64 and ppc64le
Product: [Fedora] Fedora Reporter: Nikola Forró <nforro>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 26CC: davejohansen, jakub, jwakely, law, mpolacek
Target Milestone: ---   
Target Release: ---   
Hardware: ppc64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-05-23 13:22:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Nikola Forró 2017-03-07 15:14:54 UTC
Description of problem:
vec_vmul{e,o}u{b,h} functions return incorrect results, because they compile down to instructions that differ in signedness, e.g. vec_vmuleub function compiles down to the vmulesb instruction. This also applies to generic vec_mule and vec_mulo functions when they are used with a pair of unsigned char or unsigned short arguments.


Version-Release number of selected component (if applicable):
gcc-7.0.1-0.10.fc26


How reproducible:
always


Steps to Reproduce:
1. $ cat reproducer.c
#include <limits.h>
#include <assert.h>
#include <altivec.h>

int main(void)
{
    vector unsigned char v0 = {1, 0, 0, 0, 0, 0, 0, 0};
    vector unsigned char v1 = {UCHAR_MAX, 0, 0, 0, 0, 0, 0, 0};

    vector unsigned short res = vec_vmuleub(v0, v1);

    assert(res[0] == (unsigned short)v0[0] * (unsigned short)v1[0]);
}

2. $ gcc -maltivec -mabi=altivec reproducer.c -o reproducer

3. $ ./reproducer 
reproducer: reproducer.c:12: main: Assertion `res[0] == (unsigned short)v0[0] * (unsigned short)v1[0]' failed.
Aborted (core dumped)


Actual results:
assertion fails


Expected results:
assertion succeeds


Additional info:
This affects build of libjpeg-turbo, making it generate broken images.

Comment 1 Nikola Forró 2017-05-18 14:11:18 UTC
This is fixed since gcc-7.0.1-0.15.fc26, right?

Comment 2 Jakub Jelinek 2017-05-23 13:22:07 UTC
Already since gcc-7.0.1-0.13.fc26.