[Bug tree-optimization/77283] New: Revision 238005 disables loop unrolling
bergner at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Aug 17 20:05:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77283
Bug ID: 77283
Summary: Revision 238005 disables loop unrolling
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: bergner at gcc dot gnu.org
Target Milestone: ---
Revision 238005 (richi's fix to path splitting to handle empty else blocks)
disables loop unrolling for the test case below (extracted from one of our
benchmarks) leading to a performance regression.
bergner@genoa:~/gcc/BUGS/$ cat foo.c
void
foo (double *x, double *a, double *b, long n, double limit)
{
long i;
for (i=0; i < n; i++)
if (a[i] < limit)
x[i] = b[i];
}
bergner@genoa:~/gcc/BUGS/$
/home/bergner/gcc/build/gcc-fsf-mainline-r238005/gcc/xgcc
-B/home/bergner/gcc/build/gcc-fsf-mainline-r238005/gcc -O3 -funroll-loops -S
foo.c
bergner@genoa:~/gcc/BUGS/$ cat foo.s
foo:
cmpdi 0,6,0
ble 0,.L1
sldi 6,6,3
li 9,0
.p2align 4,,15
.L3:
lfdx 0,4,9
fcmpu 7,0,1
bnl 7,.L8
lfdx 2,5,9
stfdx 2,3,9
addi 9,9,8
cmpld 5,9,6
bne 5,.L3
.L1:
blr
.p2align 4,,15
.L8:
addi 9,9,8
cmpld 1,9,6
bne 1,.L3
blr
bergner@genoa:~/gcc/BUGS/$
/home/bergner/gcc/build/gcc-fsf-mainline-r238004/gcc/xgcc
-B/home/bergner/gcc/build/gcc-fsf-mainline-r238004/gcc -O3 -funroll-loops -S
foo.c
bergner@genoa:~/gcc/BUGS/$ cat foo.s
foo:
cmpdi 0,6,0
ble 0,.L1
lfd 0,0(4)
sldi 6,6,3
addi 8,6,-8
srdi 0,8,3
rldicl 10,0,0,61
fcmpu 7,0,1
blt 7,.L8
.L59:
li 9,8
cmpld 1,9,6
beq 1,.L1
cmpdi 5,10,0
beq 5,.L30
cmpdi 6,10,1
beq 6,.L46
cmpdi 0,10,2
beq 0,.L47
cmpdi 7,10,3
beq 7,.L48
cmpdi 1,10,4
beq 1,.L49
cmpdi 5,10,5
beq 5,.L50
cmpdi 6,10,6
beq 6,.L51
lfdx 3,4,9
fcmpu 0,3,1
bnl 0,.L61
lfdx 4,5,9
stfdx 4,3,9
.L61:
addi 9,9,8
.L51:
lfdx 5,4,9
fcmpu 7,5,1
bnl 7,.L62
lfdx 6,5,9
stfdx 6,3,9
.L62:
addi 9,9,8
.L50:
lfdx 7,4,9
fcmpu 1,7,1
bnl 1,.L63
lfdx 8,5,9
stfdx 8,3,9
[snip]
An executable version of the test case above is:
bergner@genoa:~/gcc/BUGS/LTC144447$ cat loop.c
#define SIZE 1024*1000
void
__attribute__ ((noinline))
foo (double *x, double *a, double *b, long n, double limit)
{
long i;
for (i=0; i < n; i++)
if (a[i] < limit)
x[i] = b[i];
}
double x[SIZE], a[SIZE], b[SIZE];
int
main (void)
{
long i;
for (i=0; i < 3000; i++)
foo (x, a, b, SIZE, 1.0);
return 0;
}
bergner@genoa:~/gcc/BUGS/$
/home/bergner/gcc/build/gcc-fsf-mainline-r238004/gcc/xgcc
-B/home/bergner/gcc/build/gcc-fsf-mainline-r238004/gcc -O3 -funroll-loops
loop.c
bergner@genoa:~/gcc/BUGS/$ time ./a.out
real 0m3.729s
user 0m3.690s
sys 0m0.021s
bergner@genoa:~/gcc/BUGS/$
/home/bergner/gcc/build/gcc-fsf-mainline-r238005/gcc/xgcc
-B/home/bergner/gcc/build/gcc-fsf-mainline-r238005/gcc -O3 -funroll-loops
loop.c
bergner@genoa:~/gcc/BUGS/$ time ./a.out
real 0m6.939s
user 0m6.851s
sys 0m0.040s
More information about the Gcc-bugs
mailing list