- * Follow the memory chain as long as there are only Loads
- * and alias free Stores and try to replace current Load or Store
- * by a previous ones.
+ * Check whether a Call is at least pure, ie. does only read memory.
+ */
+static unsigned is_Call_pure(ir_node *call) {
+ ir_type *call_tp = get_Call_type(call);
+ unsigned prop = get_method_additional_properties(call_tp);
+
+ /* check first the call type */
+ if ((prop & (mtp_property_const|mtp_property_pure)) == 0) {
+ /* try the called entity */
+ ir_node *ptr = get_Call_ptr(call);
+
+ if (is_Global(ptr)) {
+ ir_entity *ent = get_Global_entity(ptr);
+
+ prop = get_entity_additional_properties(ent);
+ }
+ }
+ return (prop & (mtp_property_const|mtp_property_pure)) != 0;
+} /* is_Call_pure */
+
+/**
+ * Follow the memory chain as long as there are only Loads,
+ * alias free Stores, and constant Calls and try to replace the
+ * current Load by a previous ones.