summaryrefslogtreecommitdiff
path: root/gcc/simplify-rtx.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2013-05-14 08:55:34 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2013-05-14 08:55:34 +0000
commitb96ca9cafabafe2525d1b74e1ac38dc56ffc90e7 (patch)
treecf62bd2045ab3fa40d75cb48379cb1295898c3a7 /gcc/simplify-rtx.c
parent8aacb2c508252e4ad733bc4e4b9b4ec9dd461bce (diff)
downloadgcc-b96ca9cafabafe2525d1b74e1ac38dc56ffc90e7.tar.gz
* expmed.c (expand_shift_1): Canonicalize rotates by
constant bitsize / 2 to bitsize - 1. * simplify-rt.x (simplify_binary_operation_1) <case ROTATE, case ROTATERT>: Likewise. Revert: 2013-05-10 Jakub Jelinek <jakub@redhat.com> * config/i386/i386.md (rotateinv): New code attr. (*<rotate_insn><mode>3_1, *<rotate_insn>si3_1_zext, *<rotate_insn>qi3_1_slp): Emit rorl %eax instead of roll $31, %eax, etc. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@198864 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/simplify-rtx.c')
-rw-r--r--gcc/simplify-rtx.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 791f91a34a8..865d37d49c3 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -3250,6 +3250,18 @@ simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode,
case ROTATERT:
case ROTATE:
+ /* Canonicalize rotates by constant amount. If op1 is bitsize / 2,
+ prefer left rotation, if op1 is from bitsize / 2 + 1 to
+ bitsize - 1, use other direction of rotate with 1 .. bitsize / 2 - 1
+ amount instead. */
+ if (CONST_INT_P (trueop1)
+ && IN_RANGE (INTVAL (trueop1),
+ GET_MODE_BITSIZE (mode) / 2 + (code == ROTATE),
+ GET_MODE_BITSIZE (mode) - 1))
+ return simplify_gen_binary (code == ROTATE ? ROTATERT : ROTATE,
+ mode, op0, GEN_INT (GET_MODE_BITSIZE (mode)
+ - INTVAL (trueop1)));
+ /* FALLTHRU */
case ASHIFTRT:
if (trueop1 == CONST0_RTX (mode))
return op0;