Hello,
I have discovered that volatile expresions can cause the tree-ssa
pre pass to loop forever in "compute_antic". The problem seems to be
that the expresion is assigned a different value number at each
iteration, hence the fixed point required to exit the loop is never reached.
This can be fixed with the attached patch, which modifies
"can_value_number_operation" to return false for volatile expresions. I
think this makes sense, because you cannot value number volatile
expresions (in the same sense that you cannot value number non pure or
const function calls).
I cannot easily provide a testcase because this problem appears only
with a gcc frontend that I am writting. With this fix, volatile acesses
work correctly (without it they work correctly only if this pass is
disabled).
Do you think this patch is correct?
Thanks,
Ricardo.
Index: gcc/tree-ssa-pre.c
===================================================================
--- gcc/tree-ssa-pre.c (revision 557)
+++ gcc/tree-ssa-pre.c (working copy)
@@ -2133,12 +2133,13 @@
static bool
can_value_number_operation (tree op)
{
- return UNARY_CLASS_P (op)
- || BINARY_CLASS_P (op)
- || COMPARISON_CLASS_P (op)
- || REFERENCE_CLASS_P (op)
- || (TREE_CODE (op) == CALL_EXPR
- && can_value_number_call (op));
+ return (UNARY_CLASS_P (op)
+ || BINARY_CLASS_P (op)
+ || COMPARISON_CLASS_P (op)
+ || REFERENCE_CLASS_P (op)
+ || (TREE_CODE (op) == CALL_EXPR
+ && can_value_number_call (op)))
+ && !TREE_THIS_VOLATILE (op);
}