summaryrefslogtreecommitdiff
path: root/gcc/simplify-rtx.c
diff options
context:
space:
mode:
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2007-02-12 01:43:50 +0000
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2007-02-12 01:43:50 +0000
commitecf8b614f9c9d6854b2f028143db8946e55c38e7 (patch)
tree0f422267ae47a4e1db8030365f255263615dd2c6 /gcc/simplify-rtx.c
parenta1f69845266b2b7417bca8606ed0d9e402a0f915 (diff)
downloadgcc-ecf8b614f9c9d6854b2f028143db8946e55c38e7.tar.gz
* simplify-rtx.c (simplify_relational_operation_1): Optimize
comparisons of POPCOUNT against zero. (simplify_const_relational_operation): Likewise. * gcc.target/ia64/builtin-popcount-1.c: New test case. * gcc.target/ia64/builtin-popcount-2.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121838 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/simplify-rtx.c')
-rw-r--r--gcc/simplify-rtx.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 8d8bbe52d0c..6f7c37d4c56 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -3802,6 +3802,27 @@ simplify_relational_operation_1 (enum rtx_code code, enum machine_mode mode,
simplify_gen_binary (XOR, cmp_mode,
XEXP (op0, 1), op1));
+ if (op0code == POPCOUNT && op1 == const0_rtx)
+ switch (code)
+ {
+ case EQ:
+ case LE:
+ case LEU:
+ /* (eq (popcount x) (const_int 0)) -> (eq x (const_int 0)). */
+ return simplify_gen_relational (EQ, mode, GET_MODE (XEXP (op0, 0)),
+ XEXP (op0, 0), const0_rtx);
+
+ case NE:
+ case GT:
+ case GTU:
+ /* (ne (popcount x) (const_int 0)) -> (ne x (const_int 0)). */
+ return simplify_gen_relational (EQ, mode, GET_MODE (XEXP (op0, 0)),
+ XEXP (op0, 0), const0_rtx);
+
+ default:
+ break;
+ }
+
return NULL_RTX;
}
@@ -4067,6 +4088,10 @@ simplify_const_relational_operation (enum rtx_code code,
if (GET_CODE (tem) == ABS)
return const0_rtx;
}
+
+ /* Optimize popcount (x) < 0. */
+ if (GET_CODE (trueop0) == POPCOUNT && trueop1 == const0_rtx)
+ return const_true_rtx;
break;
case GE:
@@ -4081,6 +4106,10 @@ simplify_const_relational_operation (enum rtx_code code,
if (GET_CODE (tem) == ABS)
return const_true_rtx;
}
+
+ /* Optimize popcount (x) >= 0. */
+ if (GET_CODE (trueop0) == POPCOUNT && trueop1 == const0_rtx)
+ return const_true_rtx;
break;
case UNGE: