diff options
author | Jakub Jelinek <jakub@redhat.com> | 2011-11-10 16:36:48 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2011-11-10 16:36:48 +0100 |
commit | 03989f55955ddb1f82ce79a7c2251039d0ba5d0e (patch) | |
tree | 3c906560b2c9e0caabf7c866135d739cfc9868d4 /gcc/combine.c | |
parent | 4da80bfb5d2e188674abdf5461876108e77ab881 (diff) | |
download | gcc-03989f55955ddb1f82ce79a7c2251039d0ba5d0e.zip gcc-03989f55955ddb1f82ce79a7c2251039d0ba5d0e.tar.gz gcc-03989f55955ddb1f82ce79a7c2251039d0ba5d0e.tar.bz2 |
re PR rtl-optimization/51023 (likely integer wrong code bug)
PR rtl-optimization/51023
* combine.c (simplify_comparison) <case SIGN_EXTEND>: Don't use
val_signbit_known_clear_p for signed comparison narrowing
optimization. Don't check for non-VOIDmode, use
HWI_COMPUTABLE_MODE_P macro.
<case ZERO_EXTEND>: Don't check for non-VOIDmode.
Optimize even when const_op is equal to GET_MODE_MASK (mode),
don't optimize if const_op is negative.
* gcc.c-torture/execute/pr51023.c: New test.
From-SVN: r181257
Diffstat (limited to 'gcc/combine.c')
-rw-r--r-- | gcc/combine.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/gcc/combine.c b/gcc/combine.c index ad9aa38..1714c74 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -11397,9 +11397,10 @@ simplify_comparison (enum rtx_code code, rtx *pop0, rtx *pop1) later on, and then we wouldn't know whether to sign- or zero-extend. */ mode = GET_MODE (XEXP (op0, 0)); - if (mode != VOIDmode && GET_MODE_CLASS (mode) == MODE_INT + if (GET_MODE_CLASS (mode) == MODE_INT && ! unsigned_comparison_p - && val_signbit_known_clear_p (mode, const_op) + && HWI_COMPUTABLE_MODE_P (mode) + && trunc_int_for_mode (const_op, mode) == const_op && have_insn_for (COMPARE, mode)) { op0 = XEXP (op0, 0); @@ -11477,10 +11478,11 @@ simplify_comparison (enum rtx_code code, rtx *pop0, rtx *pop1) case ZERO_EXTEND: mode = GET_MODE (XEXP (op0, 0)); - if (mode != VOIDmode && GET_MODE_CLASS (mode) == MODE_INT + if (GET_MODE_CLASS (mode) == MODE_INT && (unsigned_comparison_p || equality_comparison_p) && HWI_COMPUTABLE_MODE_P (mode) - && ((unsigned HOST_WIDE_INT) const_op < GET_MODE_MASK (mode)) + && (unsigned HOST_WIDE_INT) const_op <= GET_MODE_MASK (mode) + && const_op >= 0 && have_insn_for (COMPARE, mode)) { op0 = XEXP (op0, 0); |