diff mbox

Fix canonical form of true/false conditions

Message ID alpine.LSU.2.11.1507221336360.19642@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener July 22, 2015, 11:39 a.m. UTC
Currently fold_stmt via gimple_cond_set_condition_from_tree and
gimple_cond_get_ops_from_tree and gimple_cond_make_false and
gimple_cond_make_true do not agree on the canonical form of
if (true) and if (false) resulting in spurious foldings.

The following makes gimple_cond_make_false/true follow the
!= 0 canoncalization that gimple_cond_get_ops_from_tree performs
and thus produce already folded conditions.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Richard.

2015-07-22  Richard Biener  <rguenther@suse.de>

	* gimple.h (gimple_cond_make_false): Use 0 != 0.
	(gimple_cond_make_true): Use 1 != 0.
diff mbox

Patch

Index: gcc/gimple.h
===================================================================
--- gcc/gimple.h	(revision 226059)
+++ gcc/gimple.h	(working copy)
@@ -3187,9 +3187,9 @@  gimple_cond_false_label (const gcond *gs
 static inline void
 gimple_cond_make_false (gcond *gs)
 {
-  gimple_cond_set_lhs (gs, boolean_true_node);
+  gimple_cond_set_lhs (gs, boolean_false_node);
   gimple_cond_set_rhs (gs, boolean_false_node);
-  gs->subcode = EQ_EXPR;
+  gs->subcode = NE_EXPR;
 }
 
 
@@ -3199,8 +3199,8 @@  static inline void
 gimple_cond_make_true (gcond *gs)
 {
   gimple_cond_set_lhs (gs, boolean_true_node);
-  gimple_cond_set_rhs (gs, boolean_true_node);
-  gs->subcode = EQ_EXPR;
+  gimple_cond_set_rhs (gs, boolean_false_node);
+  gs->subcode = NE_EXPR;
 }
 
 /* Check if conditional statemente GS is of the form 'if (1 == 1)',