https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106692
anlauf at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Known to work| |6.4.1 CC| |anlauf at gcc dot gnu.org Known to fail|7.5.0 |7.4.1 --- Comment #15 from anlauf at gcc dot gnu.org --- (In reply to Tobias Burnus from comment #13) > > What do others think? > > I am a bit unsure. Cray pointers are weird and it is not quite clear how > they are used in real world code. > > Your modification causes a missed optimization for code like: > > var = NULL > if (var == NULL) > > as the volatile not only prevents seeing this but also reloads the variable > instead of using the value in the register. > > But as Cray pointers are weird, pointer checks are rare and volatile is > localized, it might actually be okay? I have tried replacing TREE_VOLATILE by TREE_STATIC, i.e. + // Hack: prevent optimization of comparison of Cray pointers (PR106692) + if (expr->value.op.op1->expr_type == EXPR_VARIABLE + && expr->value.op.op1->ts.type == BT_INTEGER + && expr->value.op.op1->symtree + && expr->value.op.op1->symtree->n.sym->attr.cray_pointer) + TREE_STATIC (lse.expr) = 1; [...] and this works too. The optimized dump shows that the above if () is still optimized away at -Og and higher, unless there is a PRINT statement in between. (Another missed optimization around PRINT statements?). Any other suggestion? Otherwise I'll wrap up and submit.