diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2016-10-17 22:15:02 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2016-10-17 22:15:02 +0000 |
commit | ea000c3ff59fa6c3e660766e4876d29bc1f5f575 (patch) | |
tree | 3de01aa3cab124e106c14bbb7e456b34f0b96a5b /gcc/expmed.c | |
parent | a929f2662ef33c06ad5b41f2a3df0c0833bbc405 (diff) | |
download | gcc-ea000c3ff59fa6c3e660766e4876d29bc1f5f575.zip gcc-ea000c3ff59fa6c3e660766e4876d29bc1f5f575.tar.gz gcc-ea000c3ff59fa6c3e660766e4876d29bc1f5f575.tar.bz2 |
expmed.c (expand_shift_1): Add MAY_FAIL parameter and do not assert that the result is non-zero if it is true.
* expmed.c (expand_shift_1): Add MAY_FAIL parameter and do not assert
that the result is non-zero if it is true.
(maybe_expand_shift): New wrapper around expand_shift_1.
(emit_store_flag): Call maybe_expand_shift in lieu of expand_shift.
From-SVN: r241282
Diffstat (limited to 'gcc/expmed.c')
-rw-r--r-- | gcc/expmed.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/gcc/expmed.c b/gcc/expmed.c index fec0bbd..69109db 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -2248,11 +2248,13 @@ expand_dec (rtx target, rtx dec) and AMOUNT the rtx for the amount to shift by. Store the result in the rtx TARGET, if that is convenient. If UNSIGNEDP is nonzero, do a logical shift; otherwise, arithmetic. - Return the rtx for where the value is. */ + Return the rtx for where the value is. + If that cannot be done, abort the compilation unless MAY_FAIL is true, + in which case 0 is returned. */ static rtx expand_shift_1 (enum tree_code code, machine_mode mode, rtx shifted, - rtx amount, rtx target, int unsignedp) + rtx amount, rtx target, int unsignedp, bool may_fail = false) { rtx op1, temp = 0; int left = (code == LSHIFT_EXPR || code == LROTATE_EXPR); @@ -2449,7 +2451,7 @@ expand_shift_1 (enum tree_code code, machine_mode mode, rtx shifted, define_expand for lshrsi3 was added to vax.md. */ } - gcc_assert (temp); + gcc_assert (temp != NULL_RTX || may_fail); return temp; } @@ -2468,6 +2470,16 @@ expand_shift (enum tree_code code, machine_mode mode, rtx shifted, shifted, GEN_INT (amount), target, unsignedp); } +/* Likewise, but return 0 if that cannot be done. */ + +static rtx +maybe_expand_shift (enum tree_code code, machine_mode mode, rtx shifted, + int amount, rtx target, int unsignedp) +{ + return expand_shift_1 (code, mode, + shifted, GEN_INT (amount), target, unsignedp, true); +} + /* Output a shift instruction for expression code CODE, with SHIFTED being the rtx for the value to shift, and AMOUNT the tree for the amount to shift by. @@ -5754,11 +5766,12 @@ emit_store_flag (rtx target, enum rtx_code code, rtx op0, rtx op1, if (rtx_equal_p (subtarget, op0)) subtarget = 0; - tem = expand_shift (RSHIFT_EXPR, mode, op0, - GET_MODE_BITSIZE (mode) - 1, - subtarget, 0); - tem = expand_binop (mode, sub_optab, tem, op0, subtarget, 0, - OPTAB_WIDEN); + tem = maybe_expand_shift (RSHIFT_EXPR, mode, op0, + GET_MODE_BITSIZE (mode) - 1, + subtarget, 0); + if (tem) + tem = expand_binop (mode, sub_optab, tem, op0, subtarget, 0, + OPTAB_WIDEN); } if (code == EQ || code == NE) @@ -5820,9 +5833,9 @@ emit_store_flag (rtx target, enum rtx_code code, rtx op0, rtx op1, } if (tem && normalizep) - tem = expand_shift (RSHIFT_EXPR, mode, tem, - GET_MODE_BITSIZE (mode) - 1, - subtarget, normalizep == 1); + tem = maybe_expand_shift (RSHIFT_EXPR, mode, tem, + GET_MODE_BITSIZE (mode) - 1, + subtarget, normalizep == 1); if (tem) { |