https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71836
Bug ID: 71836
Summary: Missing constant prop from const variable
Product: gcc
Version: 6.1.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Target: aarch64*-*-*
Take:
#include <stdio.h>
#include <float.h>
int main()
{
float a[] __attribute__((aligned(0x20))) = {0, 1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16};
float maxval = -FLT_MAX;
for (size_t i = 0; i < 16; i++)
maxval = a[i] > maxval ? a[i] : maxval;
printf("%g\n", maxval);
}
---- CUT ----
Currently on aarch64-linux-gnu we get:
a = *.LC0;
_17 = a[0];
iftmp.0_18 = _17 > -3.4028234663852885981170418348451692544e+38 ? _17 :
-3.4028234663852885981170418348451692544e+38;
_24 = a[1];
iftmp.0_25 = iftmp.0_18 < _24 ? _24 : iftmp.0_18;
_31 = a[2];
--- CUT ---
Depending on the scheduler, GCC can remove even more extra load/stores
(thunderx scheduler will cause GCC not to remove them while cortex-a57 will).
But really any load/stores here is not useful as a[0] can be found in .LC0[0].