Add a rule to transform x .op. (x .op. y) into y .op. (x .op. x) for commutative...
[libfirm] / ir / opt / opt_confirms.c
index a42b1f2..3fd45f7 100644 (file)
@@ -23,9 +23,7 @@
  * @author  Michael Beck
  * @version $Id$
  */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include "config.h"
 
 #undef DEBUG_CONFIRM
 
@@ -97,7 +95,7 @@ static tarval *compare_iv_dbg(const interval_t *l_iv, const interval_t *r_iv, pn
  * This is a often needed case, so we handle here Confirm
  * nodes too.
  */
-int value_not_zero(ir_node *n, ir_node **confirm) {
+int value_not_zero(const ir_node *n, ir_node_cnst_ptr *confirm) {
 #define RET_ON(x)  if (x) { *confirm = n; return 1; }; break
 
        tarval *tv;
@@ -175,11 +173,11 @@ int value_not_zero(ir_node *n, ir_node **confirm) {
  * - A SymConst(entity) is NEVER a NULL pointer
  * - Confirms are evaluated
  */
-int value_not_null(ir_node *n, ir_node **confirm) {
+int value_not_null(const ir_node *n, ir_node_cnst_ptr *confirm) {
        tarval *tv;
 
        *confirm = NULL;
-       n  = skip_Cast(n);
+       n  = skip_Cast_const(n);
 
        tv = value_of(n);
        if (tarval_is_constant(tv) && ! tarval_is_null(tv))
@@ -241,7 +239,7 @@ value_classify_sign classify_value_sign(ir_node *n) {
                }
                break;
        }
-       if (get_irn_op(n) != op_Confirm)
+       if (!is_Confirm(n))
                return value_classified_unknown;
 
        tv  = value_of(get_Confirm_bound(n));
@@ -769,8 +767,8 @@ check_null_case:
                if ((pnc == pn_Cmp_Eq || pnc == pn_Cmp_Lg) &&
                        is_Const(right) && is_Const_null(right)) {
                        /* for == 0 or != 0 we have some special tools */
-                       ir_mode *mode = get_irn_mode(left);
-                       ir_node *dummy;
+                       ir_mode       *mode = get_irn_mode(left);
+                       const ir_node *dummy;
                        if (mode_is_reference(mode)) {
                                if (value_not_null(left, &dummy)) {
                                        tv = pnc == pn_Cmp_Eq ? tarval_b_false : tarval_b_true;