From 8861704d23452518ecba127c7fd26faf447f9c71 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 6 Aug 2015 08:45:52 +0000 Subject: [PATCH] gimple-fold.c (gimple_fold_stmt_to_constant_1): Simplify bool comparison canonicalization and restrict to integers. 2015-08-06 Richard Biener * gimple-fold.c (gimple_fold_stmt_to_constant_1): Simplify bool comparison canonicalization and restrict to integers. From-SVN: r226668 --- gcc/ChangeLog | 5 +++++ gcc/gimple-fold.c | 20 ++++++-------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 646dd18d044..e0826e7f048 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2015-08-06 Richard Biener + + * gimple-fold.c (gimple_fold_stmt_to_constant_1): Simplify + bool comparison canonicalization and restrict to integers. + 2015-08-05 Andrew MacLeod * coretypes.h (enum symbol_visibility): Relocate here. diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 1a70d8ff722..de64c053f3a 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -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; -- 2.30.2