[cfe-dev] C/C++ operator meaning is different between gcc generic vector type and altivec type

Jinsong Ji via cfe-dev cfe-dev at lists.llvm.org
Thu Oct 18 12:53:32 PDT 2018


Hi Hubert:

Looks like the interpretation of ABI should be the opposite of your
understanding.

"The ABI (as cited by Hubert) clearly means that all of the operators
described there are to operate independently on each lane.  Vector binary
addition is not "sum across", so why should vector <= mean vec_all_le (or
vec_any_le, for that matter)?  The result of <= should be a vector of
booleans."



Best,

Jinsong Ji (¼Í½ðËÉ), PhD.

XL C/C++, XL Fortran Compiler Development
E-mail: jji at us.ibm.com



From:	Hubert Tong/Toronto/IBM
To:	Zi Xuan CW Wu/China/IBM at IBMCN
Cc:	cfe-dev at lists.llvm.org, Jinsong Ji/Jacksonville/IBM at IBMUS,
            Nemanja Ivanovic/Toronto/IBM at IBMCA
Date:	10/18/2018 10:03 AM
Subject:	Re: C/C++ operator meaning is different between gcc generic
            vector type and altivec type


The OpenPOWER ABI for Linux Supplement for the Power Architecture 64-bit
ELF V2 ABI documents the following under Section 6.2. "Vector Operators":

The traditional C/C++ operators are defined on vector types with ¡°do all¡±
semantics for unary and binary +, unary and binary ¨C, binary *, binary %,
and binary / as well as the unary and binary shift, logical and comparison
operators, and the ternary ?: operator.

So the answer is the the two kinds of vectors have separate semantics and
Clang is right.

-- HT




From:	Zi Xuan CW Wu/China/IBM
To:	cfe-dev at lists.llvm.org
Cc:	Jinsong Ji/Jacksonville/IBM at IBMUS, Nemanja
            Ivanovic/Toronto/IBM at IBMCA, Hubert Tong/Toronto/IBM at IBMCA
Date:	18-10-2018 02:18 a.m.
Subject:	C/C++ operator meaning is different between gcc generic vector
            type and altivec type



Hi, all.

I find the meaning of C/C++ language operator '<=' is different between
different vector kind type. For example, a legal clang code as following.
But it's ill-formed in GCC.
     typedef int v4 __attribute((vector_size(16)));

     int main(){
       v4 va;
       v4 vb;
       vector int a;
       vector int b;

       int c = a<=b;
       v4 vc = va<=vb;

     }

     g++ a.C
     a.C: In function 'int main()':
     a.C:9:14: error: cannot convert '__vector(4) int' to 'int' in
     initialization
        int c = a<=b;


The return type of '<=' operator of Altivec kind vector is not same as
generic gcc kind vector. One is int, the other one is vector. But in GCC,
it's same return type and meaning, which is described at
https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html

So my question is what it is we would like relational and equality
operators to do with vectors? We make the meaning of two kind vectors
consistent or separate? Or which document is standard rule to implement the
semantic meaning?


Regards,


Zixuan Wu (Zeson)

XL C/C++ Compiler Developer
IBM Systems, z System
E-mail: wuzish at cn.ibm.com
Tel: 86-21-60928420

Compiler : The Art of Lowering



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181018/5ee5f2ef/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181018/5ee5f2ef/attachment-0001.gif>


More information about the cfe-dev mailing list