]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR tree-optimization/70005
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 1 Mar 2016 00:04:48 +0000 (00:04 +0000)
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 1 Mar 2016 00:04:48 +0000 (00:04 +0000)
* tree-ssa-uncprop.c (associate_equivalences_with_edges): Handle case
where an object with a boolean range is compared against a value
outside [0..1].

PR tree-optimization/70005
* gcc.c-torture/execute/pr70005.c New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233829 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr70005.c [new file with mode: 0644]
gcc/tree-ssa-uncprop.c

index 653b51e764b26d20ce82003804080470a9db8c7d..ccbcfe8676daf351014fc3208eaa82b08cecadda 100644 (file)
@@ -1,5 +1,10 @@
 2016-02-28  Jeff Law  <law@redhat.com>
 
+       PR tree-optimization/70005
+       * tree-ssa-uncprop.c (associate_equivalences_with_edges): Handle case
+       where an object with a boolean range is compared against a value
+       outside [0..1].
+
        PR tree-optimization/69999
        * gimple-ssa-split-paths.c (split_paths): When duplicating a block
        with an outgoing edge marked with EDGE_IRREDUCIBLE_LOOP, schedule
index 49577ee87a3c3f21dc3c5b7857c81b9e8e16040b..3743d347b96955dcdb437e441a133b258b25d7d9 100644 (file)
@@ -1,5 +1,8 @@
 2016-02-29  Jeff Law  <law@redhat.com>
 
+       PR tree-optimization/70005
+       * gcc.c-torture/execute/pr70005.c New test.
+
        PR tree-optimization/69999
        * gcc.c-torture/compile/pr69999.c: New test.
 
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr70005.c b/gcc/testsuite/gcc.c-torture/execute/pr70005.c
new file mode 100644 (file)
index 0000000..bc37efe
--- /dev/null
@@ -0,0 +1,25 @@
+
+unsigned char a = 6;
+int b, c;
+
+static void
+fn1 ()
+{
+  int i = a > 1 ? 1 : a, j = 6 & (c = a && (b = a));
+  int d = 0, e = a, f = ~c, g = b || a;
+  unsigned char h = ~a;
+  if (a)
+    f = j;
+  if (h && g)
+    d = a;
+  i = -~(f * d * h) + c && (e || i) ^ f;
+  if (i != 1) 
+    __builtin_abort (); 
+}
+
+int
+main ()
+{
+  fn1 ();
+  return 0; 
+}
index 307bb1fd134047245fa8e9be434e4b8960fb7af9..e2e82123c35bf43a9d4b454c056ac3c762512193 100644 (file)
@@ -95,7 +95,8 @@ associate_equivalences_with_edges (void)
              if (TREE_CODE (op0) == SSA_NAME
                  && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (op0)
                  && ssa_name_has_boolean_range (op0)
-                 && is_gimple_min_invariant (op1))
+                 && is_gimple_min_invariant (op1)
+                 && (integer_zerop (op1) || integer_onep (op1)))
                {
                  tree true_val = constant_boolean_node (true, TREE_TYPE (op0));
                  tree false_val = constant_boolean_node (false,