aboutsummaryrefslogtreecommitdiff
path: root/gcc/expmed.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2013-05-14 10:55:34 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2013-05-14 10:55:34 +0200
commit75776c6d256cf2db9cd470484445bff01c7e30fa (patch)
treecf62bd2045ab3fa40d75cb48379cb1295898c3a7 /gcc/expmed.c
parentdf35498ae56e297e0de7279127cab265e71fc2d2 (diff)
downloadgcc-75776c6d256cf2db9cd470484445bff01c7e30fa.zip
gcc-75776c6d256cf2db9cd470484445bff01c7e30fa.tar.gz
gcc-75776c6d256cf2db9cd470484445bff01c7e30fa.tar.bz2
expmed.c (expand_shift_1): Canonicalize rotates by constant bitsize / 2 to bitsize - 1.
* 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. From-SVN: r198864
Diffstat (limited to 'gcc/expmed.c')
-rw-r--r--gcc/expmed.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/expmed.c b/gcc/expmed.c
index 6e61e9a..c85e68c 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -2122,6 +2122,20 @@ expand_shift_1 (enum tree_code code, enum machine_mode mode, rtx shifted,
op1 = SUBREG_REG (op1);
}
+ /* 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 (rotate
+ && CONST_INT_P (op1)
+ && IN_RANGE (INTVAL (op1), GET_MODE_BITSIZE (mode) / 2 + left,
+ GET_MODE_BITSIZE (mode) - 1))
+ {
+ op1 = GEN_INT (GET_MODE_BITSIZE (mode) - INTVAL (op1));
+ left = !left;
+ code = left ? LROTATE_EXPR : RROTATE_EXPR;
+ }
+
if (op1 == const0_rtx)
return shifted;