From: Bernd Schmidt <bernds@codesourcery.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [1/11] Use targetm.shift_truncation_mask more consistently
Date: Fri, 01 Jul 2011 17:27:00 -0000 [thread overview]
Message-ID: <4E0E0389.5040505@codesourcery.com> (raw)
In-Reply-To: <4E0E0310.60406@codesourcery.com>
[-- Attachment #1: Type: text/plain, Size: 168 bytes --]
At some point we've grown a shift_truncation_mask hook, but we're not
using it everywhere we're masking shift counts. This patch changes the
instances I found.
Bernd
[-- Attachment #2: 01-truncmask.diff --]
[-- Type: text/plain, Size: 1873 bytes --]
* simplify-rtx.c (simplify_const_binary_operation): Use the
shift_truncation_mask hook instead of performing modulo by
width. Compare against mode precision, not bitsize.
* combine.c (combine_simplify_rtx, simplify_shift_const_1):
Use shift_truncation_mask instead of constructing the value
manually.
Index: gcc/simplify-rtx.c
===================================================================
--- gcc/simplify-rtx.c.orig
+++ gcc/simplify-rtx.c
@@ -3704,8 +3704,8 @@ simplify_const_binary_operation (enum rt
shift_truncation_mask, since the shift might not be part of an
ashlM3, lshrM3 or ashrM3 instruction. */
if (SHIFT_COUNT_TRUNCATED)
- arg1 = (unsigned HOST_WIDE_INT) arg1 % width;
- else if (arg1 < 0 || arg1 >= GET_MODE_BITSIZE (mode))
+ arg1 &= targetm.shift_truncation_mask (mode);
+ else if (arg1 < 0 || arg1 >= GET_MODE_PRECISION (mode))
return 0;
val = (code == ASHIFT
Index: gcc/combine.c
===================================================================
--- gcc/combine.c.orig
+++ gcc/combine.c
@@ -5941,9 +5941,7 @@ combine_simplify_rtx (rtx x, enum machin
else if (SHIFT_COUNT_TRUNCATED && !REG_P (XEXP (x, 1)))
SUBST (XEXP (x, 1),
force_to_mode (XEXP (x, 1), GET_MODE (XEXP (x, 1)),
- ((unsigned HOST_WIDE_INT) 1
- << exact_log2 (GET_MODE_BITSIZE (GET_MODE (x))))
- - 1,
+ targetm.shift_truncation_mask (GET_MODE (x)),
0));
break;
@@ -9896,7 +9894,7 @@ simplify_shift_const_1 (enum rtx_code co
want to do this inside the loop as it makes it more difficult to
combine shifts. */
if (SHIFT_COUNT_TRUNCATED)
- orig_count &= GET_MODE_BITSIZE (mode) - 1;
+ orig_count &= targetm.shift_truncation_mask (mode);
/* If we were given an invalid count, don't do anything except exactly
what was requested. */
next prev parent reply other threads:[~2011-07-01 17:27 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-01 17:26 [0/11] GET_MODE_PRECISION vs GET_MODE_BITSIZE Bernd Schmidt
2011-07-01 17:27 ` Bernd Schmidt [this message]
2011-07-04 15:29 ` [1/11] Use targetm.shift_truncation_mask more consistently Richard Henderson
2011-07-06 18:13 ` Richard Sandiford
2011-07-07 0:03 ` Bernd Schmidt
2011-07-07 8:07 ` Richard Sandiford
2011-07-01 17:30 ` [2/11] Neater tests for signbits Bernd Schmidt
2011-07-05 19:10 ` Richard Henderson
2011-07-05 21:35 ` Bernd Schmidt
2011-07-01 17:30 ` [3/11] Remove some dead code Bernd Schmidt
2011-07-05 19:12 ` Richard Henderson
2011-07-01 17:32 ` [4/11] Use precisions for TRULY_NOOP_TRUNCATION Bernd Schmidt
2011-07-05 19:16 ` Richard Henderson
2011-07-01 17:33 ` [5/11] Neater tests for paradoxical subregs Bernd Schmidt
2011-07-05 19:19 ` Richard Henderson
2011-07-01 17:34 ` [6/11] Tests for HOST_WIDE_INT representability Bernd Schmidt
2011-07-05 19:19 ` Richard Henderson
2011-07-01 17:36 ` [7/11] rtl optimizer changes Bernd Schmidt
2011-07-06 18:25 ` Richard Henderson
2011-07-01 17:37 ` [8/11] Expander changes Bernd Schmidt
2011-07-06 18:26 ` Richard Henderson
2011-07-01 17:38 ` [9/11] Fix units mismatch in comparison Bernd Schmidt
2011-07-06 18:27 ` Richard Henderson
2011-07-01 17:41 ` [10/11] Expander fixes for 40-bit integers Bernd Schmidt
2011-07-06 18:37 ` Richard Henderson
2011-07-01 17:42 ` [11/11] Fix get_mode_bounds Bernd Schmidt
2011-07-06 18:38 ` Richard Henderson
2011-07-06 23:16 ` Bernd Schmidt
2011-07-06 23:39 ` Richard Henderson
2011-07-11 10:38 ` Bernd Schmidt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E0E0389.5040505@codesourcery.com \
--to=bernds@codesourcery.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).