From d41638e4c5e0ad186c72cc8af1786b5319c684f6 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Mon, 29 May 2000 00:40:51 -0700 Subject: [PATCH] combine.c (force_to_mode): Convert subtraction from a constant to NEG or NOT when conditions allow. * combine.c (force_to_mode) [MINUS]: Convert subtraction from a constant to NEG or NOT when conditions allow. From-SVN: r34248 --- gcc/ChangeLog | 3 +++ gcc/combine.c | 23 ++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 11cfe533520..d49783c626c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,8 @@ 2000-05-29 Richard Henderson + * combine.c (force_to_mode) [MINUS]: Convert subtraction from + a constant to NEG or NOT when conditions allow. + * combine.c (combine_simplify_rtx): Don't create an if_then_else unless both args are general_operand. Don't canonicalize plus to ior unless it helps. diff --git a/gcc/combine.c b/gcc/combine.c index d4af90e54eb..47642f3d42f 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -6846,7 +6846,6 @@ force_to_mode (x, mode, mask, reg, just_select) /* ... fall through ... */ - case MINUS: case MULT: /* For PLUS, MINUS and MULT, we need any bits less significant than the most significant bit in MASK since carries from those bits will @@ -6854,6 +6853,28 @@ force_to_mode (x, mode, mask, reg, just_select) mask = fuller_mask; goto binop; + case MINUS: + /* If X is (minus C Y) where C's least set bit is larger than any bit + in the mask, then we may replace with (neg Y). */ + if (GET_CODE (XEXP (x, 0)) == CONST_INT + && (INTVAL (XEXP (x, 0)) & -INTVAL (XEXP (x, 0))) > mask) + { + x = gen_unary (NEG, GET_MODE (x), GET_MODE (x), XEXP (x, 1)); + return force_to_mode (x, mode, mask, reg, next_select); + } + + /* Similarly, if C contains every bit in the mask, then we may + replace with (not Y). */ + if (GET_CODE (XEXP (x, 0)) == CONST_INT + && (INTVAL (XEXP (x, 0)) | mask) == INTVAL (XEXP (x, 0))) + { + x = gen_unary (NOT, GET_MODE (x), GET_MODE (x), XEXP (x, 1)); + return force_to_mode (x, mode, mask, reg, next_select); + } + + mask = fuller_mask; + goto binop; + case IOR: case XOR: /* If X is (ior (lshiftrt FOO C1) C2), try to commute the IOR and -- 2.30.2