re PR middle-end/38878 (gcc.dg/tree-ssa/foldaddr-1.c XFAILed)
authorJakub Jelinek <jakub@redhat.com>
Mon, 14 Mar 2011 20:12:16 +0000 (21:12 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 14 Mar 2011 20:12:16 +0000 (21:12 +0100)
PR middle-end/38878
* fold-const.c (fold_binary_loc) <case EQ_EXPR, NE_EXPR>: Add
STRIP_NOPS on arg0 and arg1.  When optimizing X +- C == X
and C - X == X also strip nops from +/-/p+ operand.
When optimizing -X == C, fold C to arg0's type.

* gcc.dg/tree-ssa/foldaddr-1.c: Remove xfail.

From-SVN: r170957

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/foldaddr-1.c

index a9d4d62072746f37249074cdd18729dd24870932..d437a6036c61a9a5dd50c117fa5924738d6a4100 100644 (file)
@@ -1,5 +1,11 @@
 2011-03-14  Jakub Jelinek  <jakub@redhat.com>
 
+       PR middle-end/38878
+       * fold-const.c (fold_binary_loc) <case EQ_EXPR, NE_EXPR>: Add
+       STRIP_NOPS on arg0 and arg1.  When optimizing X +- C == X
+       and C - X == X also strip nops from +/-/p+ operand.
+       When optimizing -X == C, fold C to arg0's type.
+
        PR debug/47946
        * dwarf2out.c (add_bit_offset_attribute): If bit_offset is negative,
        emit it as add_AT_int instead of add_AT_unsigned.
index 957049c0a46cdeba1a73366853b47f0c257c326b..354aa4f68c62a26dbbf8a2fa0dba38a9db61b03a 100644 (file)
@@ -12112,6 +12112,9 @@ fold_binary_loc (location_t loc,
 
     case EQ_EXPR:
     case NE_EXPR:
+      STRIP_NOPS (arg0);
+      STRIP_NOPS (arg1);
+
       tem = fold_comparison (loc, code, type, op0, op1);
       if (tem != NULL_TREE)
        return tem;
@@ -12194,7 +12197,8 @@ fold_binary_loc (location_t loc,
       /* Similarly for a NEGATE_EXPR.  */
       if (TREE_CODE (arg0) == NEGATE_EXPR
          && TREE_CODE (arg1) == INTEGER_CST
-         && 0 != (tem = negate_expr (arg1))
+         && 0 != (tem = negate_expr (fold_convert_loc (loc, TREE_TYPE (arg0),
+                                                       arg1)))
          && TREE_CODE (tem) == INTEGER_CST
          && !TREE_OVERFLOW (tem))
        return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 0), tem);
@@ -12214,7 +12218,9 @@ fold_binary_loc (location_t loc,
       if ((TREE_CODE (arg0) == PLUS_EXPR
           || TREE_CODE (arg0) == POINTER_PLUS_EXPR
           || TREE_CODE (arg0) == MINUS_EXPR)
-         && operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0)
+         && operand_equal_p (tree_strip_nop_conversions (TREE_OPERAND (arg0,
+                                                                       0)),
+                             arg1, 0)
          && (INTEGRAL_TYPE_P (TREE_TYPE (arg0))
              || POINTER_TYPE_P (TREE_TYPE (arg0))))
        {
@@ -12230,7 +12236,9 @@ fold_binary_loc (location_t loc,
       /* Transform comparisons of the form C - X CMP X if C % 2 == 1.  */
       if (TREE_CODE (arg0) == MINUS_EXPR
          && TREE_CODE (TREE_OPERAND (arg0, 0)) == INTEGER_CST
-         && operand_equal_p (TREE_OPERAND (arg0, 1), arg1, 0)
+         && operand_equal_p (tree_strip_nop_conversions (TREE_OPERAND (arg0,
+                                                                       1)),
+                             arg1, 0)
          && (TREE_INT_CST_LOW (TREE_OPERAND (arg0, 0)) & 1) == 1)
        {
          return omit_two_operands_loc (loc, type,
index 1206685e8592063eed7725083bf913679e5314cc..4c1bea9595ed4a74ad485413c3e3804857069f76 100644 (file)
@@ -1,3 +1,8 @@
+2011-03-14  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/38878
+       * gcc.dg/tree-ssa/foldaddr-1.c: Remove xfail.
+
 2011-03-14  Uros Bizjak  <ubizjak@gmail.com>
 
        * gcc.target/i386/sse4_1-floor-vec.c: New test.
index a3c6a2ece88e24475f70cad2d3bc16c5df40954a..d74022e4b52b15ce079baa5c1e8face0f27d1846 100644 (file)
@@ -11,6 +11,6 @@ int foo(char *b)
 /* Folding should have determined that the two addresses were
    not identical and thus collapsed the function into a trivial
    "return 0".  */
-/* { dg-final { scan-tree-dump-times "return 0" 1 "original" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "return 0" 1 "original" } } */
 /* { dg-final { cleanup-tree-dump "original" } } */