gimple-fold.c (gimple_fold_stmt_to_constant_1): Simplify bool comparison canonicaliza...
authorRichard Biener <rguenther@suse.de>
Thu, 6 Aug 2015 08:45:52 +0000 (08:45 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 6 Aug 2015 08:45:52 +0000 (08:45 +0000)
2015-08-06  Richard Biener  <rguenther@suse.de>

* gimple-fold.c (gimple_fold_stmt_to_constant_1): Simplify
bool comparison canonicalization and restrict to integers.

From-SVN: r226668

gcc/ChangeLog
gcc/gimple-fold.c

index 646dd18d044e06a8c3c422f7b5966f9b433299a8..e0826e7f04849d1e284896f91c46bcaaf09e7cb2 100644 (file)
@@ -1,3 +1,8 @@
+2015-08-06  Richard Biener  <rguenther@suse.de>
+
+       * gimple-fold.c (gimple_fold_stmt_to_constant_1): Simplify
+       bool comparison canonicalization and restrict to integers.
+
 2015-08-05  Andrew MacLeod  <amacleod@redhat.com>
 
        * coretypes.h (enum symbol_visibility): Relocate here.
index 1a70d8ff7225cd21038fe2eab05024fa1268a433..de64c053f3a55d51da98401922d0dc22079e0880 100644 (file)
@@ -5041,20 +5041,12 @@ gimple_fold_stmt_to_constant_1 (gimple stmt, tree (*valueize) (tree),
                  {
                    tree op1 = (*valueize) (gimple_assign_rhs2 (stmt));
                    op0 = (*valueize) (op0);
-                   if (subcode == NE_EXPR)
-                     {
-                       if (integer_zerop (op1))
-                         return op0;
-                       else if (integer_zerop (op0))
-                         return op1;
-                     }
-                   else
-                     {
-                       if (integer_onep (op1))
-                         return op0;
-                       else if (integer_onep (op0))
-                         return op1;
-                     }
+                   if (TREE_CODE (op0) == INTEGER_CST)
+                     std::swap (op0, op1);
+                   if (TREE_CODE (op1) == INTEGER_CST
+                       && ((subcode == NE_EXPR && integer_zerop (op1))
+                           || (subcode == EQ_EXPR && integer_onep (op1))))
+                     return op0;
                  }
              }
            return NULL_TREE;