This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to get MIN_EXPR without using deprecated min operator


Michael Cieslinski wrote:

Consider the following short program:

#include <algorithm>
void Tst1(short* __restrict__ SrcP, short* __restrict__ MinP, int Len)
{
for (int x=0; x<Len; x++)
MinP[x] = SrcP[x] <? MinP[x];
}
void Tst2(short* __restrict__ SrcP, short* __restrict__ MinP, int Len)
{
for (int x=0; x<Len; x++)
MinP[x] = std::min(SrcP[x], MinP[x]);
}



If I compile it with gcc41 -O2 -ftree-vectorize -ftree-vectorizer-verbose=5 function Tst1 gets vectorized but Tst2 not.

The reason for this is <? results in a MIN_EXPR while std::min generates a
conditional code.
My question is, how can I get a MIN_EXPR without using the deprecated min <?
operator?



Out of interest, do you get vectorisation from:

MinP[x] = (SrcP[x]<MinP[x]) ? SrcP[x] : MinP[x];

Chris


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]