Fix use of boolean_true/false_node (PR 83979)
authorRichard Sandiford <richard.sandiford@linaro.org>
Wed, 24 Jan 2018 16:22:30 +0000 (16:22 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Wed, 24 Jan 2018 16:22:30 +0000 (16:22 +0000)
r255913 changed some constant_boolean_node calls to boolean_true_node
and boolean_false_node, which meant that the returned tree didn't
always have the right type.

2018-01-24  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/
PR tree-optimization/83979
* fold-const.c (fold_comparison): Use constant_boolean_node
instead of boolean_{true,false}_node.

gcc/testsuite/
PR tree-optimization/83979
* g++.dg/pr83979.c: New test.

From-SVN: r257021

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/pr83979.c [new file with mode: 0644]

index 1b64db3..9c313b3 100644 (file)
@@ -1,3 +1,9 @@
+2018-01-24  Richard Sandiford  <richard.sandiford@linaro.org>
+
+       PR tree-optimization/83979
+       * fold-const.c (fold_comparison): Use constant_boolean_node
+       instead of boolean_{true,false}_node.
+
 2018-01-24  Jan Hubicka  <hubicka@ucw.cz>
 
        * ipa-profile.c (ipa_propagate_frequency_1): Fix logic skipping calls
index 1ea3766..744c355 100644 (file)
@@ -8572,39 +8572,39 @@ fold_comparison (location_t loc, enum tree_code code, tree type,
                {
                case EQ_EXPR:
                  if (known_eq (bitpos0, bitpos1))
-                   return boolean_true_node;
+                   return constant_boolean_node (true, type);
                  if (known_ne (bitpos0, bitpos1))
-                   return boolean_false_node;
+                   return constant_boolean_node (false, type);
                  break;
                case NE_EXPR:
                  if (known_ne (bitpos0, bitpos1))
-                   return boolean_true_node;
+                   return constant_boolean_node (true, type);
                  if (known_eq (bitpos0, bitpos1))
-                   return boolean_false_node;
+                   return constant_boolean_node (false, type);
                  break;
                case LT_EXPR:
                  if (known_lt (bitpos0, bitpos1))
-                   return boolean_true_node;
+                   return constant_boolean_node (true, type);
                  if (known_ge (bitpos0, bitpos1))
-                   return boolean_false_node;
+                   return constant_boolean_node (false, type);
                  break;
                case LE_EXPR:
                  if (known_le (bitpos0, bitpos1))
-                   return boolean_true_node;
+                   return constant_boolean_node (true, type);
                  if (known_gt (bitpos0, bitpos1))
-                   return boolean_false_node;
+                   return constant_boolean_node (false, type);
                  break;
                case GE_EXPR:
                  if (known_ge (bitpos0, bitpos1))
-                   return boolean_true_node;
+                   return constant_boolean_node (true, type);
                  if (known_lt (bitpos0, bitpos1))
-                   return boolean_false_node;
+                   return constant_boolean_node (false, type);
                  break;
                case GT_EXPR:
                  if (known_gt (bitpos0, bitpos1))
-                   return boolean_true_node;
+                   return constant_boolean_node (true, type);
                  if (known_le (bitpos0, bitpos1))
-                   return boolean_false_node;
+                   return constant_boolean_node (false, type);
                  break;
                default:;
                }
index af42b95..b5ecce0 100644 (file)
@@ -1,3 +1,8 @@
+2018-01-24  Richard Sandiford  <richard.sandiford@linaro.org>
+
+       PR tree-optimization/83979
+       * g++.dg/pr83979.c: New test.
+
 2018-01-24  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        * gcc.dg/lto/20110201-1_0.c: Remove explicit -mfloat-abi=softfp
diff --git a/gcc/testsuite/g++.dg/pr83979.c b/gcc/testsuite/g++.dg/pr83979.c
new file mode 100644 (file)
index 0000000..a39b1ea
--- /dev/null
@@ -0,0 +1,7 @@
+/* { dg-compile } */
+
+int
+foo (char* p)
+{
+  return p + 1000 < p;
+}