}
else if (code == INTEGER_CST)
{
+ /* Make into the canonical form `1 != 0` and `0 != 0`.
+ If already in the canonical form return false
+ saying nothing has been done. */
if (integer_zerop (ops[0]))
- gimple_cond_make_false (cond_stmt);
+ {
+ if (gimple_cond_false_canonical_p (cond_stmt))
+ return false;
+ gimple_cond_make_false (cond_stmt);
+ }
else
- gimple_cond_make_true (cond_stmt);
+ {
+ if (gimple_cond_true_canonical_p (cond_stmt))
+ return false;
+ gimple_cond_make_true (cond_stmt);
+ }
}
else if (!inplace)
{
return false;
}
+/* Check if conditional statement GS is in the caonical form of 'if (1 != 0)'. */
+
+inline bool
+gimple_cond_true_canonical_p (const gcond *gs)
+{
+ tree lhs = gimple_cond_lhs (gs);
+ tree rhs = gimple_cond_rhs (gs);
+ tree_code code = gimple_cond_code (gs);
+ if (code == NE_EXPR
+ && lhs == boolean_true_node
+ && rhs == boolean_false_node)
+ return true;
+ return false;
+}
+
/* Check if conditional statement GS is of the form 'if (1 != 1)',
'if (0 != 0)', 'if (1 == 0)' or 'if (0 == 1)' */
return false;
}
+/* Check if conditional statement GS is in the caonical form of 'if (0 != 0)'. */
+
+inline bool
+gimple_cond_false_canonical_p (const gcond *gs)
+{
+ tree lhs = gimple_cond_lhs (gs);
+ tree rhs = gimple_cond_rhs (gs);
+ tree_code code = gimple_cond_code (gs);
+ if (code == NE_EXPR
+ && lhs == boolean_false_node
+ && rhs == boolean_false_node)
+ return true;
+ return false;
+}
+
/* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */
inline void