https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87325
Bug ID: 87325
Summary: determine_base_object does not consider consider
address space of base expr
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: saaadhu at gcc dot gnu.org
Target Milestone: ---
determine_base_object fold_converts the result of build_fold_addr_expr to
ptr_type_node, and this causes wrong code if the addr expr is not in the
generic address space.
struct tagT {
float x, y, z;
};
const __memx struct tagT ts [3] = { {-1.0, 0.0, -1.0}, {-1.0, 0.0, -1.0},
{-1.0, 0.0, -1.0}};
volatile int n;
extern int foo(const float *a, const float *b);
extern float bar(float x, float y);
int main() {
float r;
for (int i = 0; i<n; ++i) {
r = bar(ts[i].x, ts[i].y);
if (foo (&r, &ts[i].z))
abort();
}
}
For the AVR target, the above code at -O2 causes induction variables to be
created for &ts + 12 and &ts + 16. Because of the above code, neither of them
is a const __memx float * though, which is what they should be.
Snip of *.ivopts
Selected IV set for loop 1 at float.c:14, 4 IVs:
candidate 4 (important)
var_before i_20
var_after i_14
original biv
type int
base 0
step 1
candidate 5
var_before ivtmp.9_22
var_after ivtmp.9_6
incremented before exit test
type <unnamed-unsigned:24>
base (<unnamed-unsigned:24>) ((const <address-space-7> float *) &ts + 8)
step 12
base object (void *) (&ts)
candidate 12
var_before ivtmp.16_25
var_after ivtmp.16_26
incremented at end
type unsigned short
base (unsigned short) (float *) (&ts + 16)
step 12
base object (void *) (float *) (&ts + 16)
candidate 14
var_before ivtmp.18_30
var_after ivtmp.18_31
incremented at end
type unsigned short
base (unsigned short) (float *) (&ts + 12)
step 12
base object (void *) (float *) (&ts + 12)