Jump threading in tree dom pass prevents if-conversion & following vectorization
Bingfeng Mei
bmei@broadcom.com
Thu Nov 21 15:11:00 GMT 2013
Hi,
I am doing some investigation on loops can be vectorized
by LLVM, but not GCC. One example is loop that contains
more than one if-else constructs.
typedef signed char int8;
#define FFT 128
typedef struct {
int8 exp[FFT];
} feq_t;
void test(feq_t *feq)
{
int k;
int feqMinimum = 15;
int8 *exp = feq->exp;
for (k=0;k<FFT;k++) {
exp[k] -= feqMinimum;
if(exp[k]<-15) exp[k] = -15;
if(exp[k]>15) exp[k] = 15;
}
}
Compile it with 4.8.2 on x86_64
~/install-4.8/bin/gcc ghs-algorithms_380.c -O2 -fdump-tree-ifcvt-details -ftree-vectorize -save-temps
It is not vectorized because if-else constructs are not properly
if-converted. Looking into .ifcvt file, I found the loop is not
if-converted because of bad if-else structure. One branch jumps directly
into another branch. Digging a bit deeper, I found such structure
is generated by dom1 pass doing jump threading optimization.
So recompile with
~/install-4.8/bin/gcc ghs-algorithms_380.c -O2 -fdump-tree-ifcvt-details -ftree-vectorize -save-temps -fno-tree-dominator-opts
It is magically if-converted and vectorized! Same on our target,
performance is improved greatly in this example.
It seems to me that doing jump threading for architectures
support if-conversion is not a good idea. Original if-else structures
are damaged so that if-conversion cannot proceed, so are vectorization
and maybe other optimizations. Should we try to identify those "bad"
jump threading and skip them for such architectures?
Bingfeng Mei
Broadcom UK
More information about the Gcc
mailing list