aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2013-05-10 10:41:17 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2013-05-10 10:41:17 +0200
commit6f93c0089265867666bcf71a659df21a63e0572e (patch)
tree9be19a766bc2ae8d3cb09903e3d0c0ff54f7f5b5
parentcb3b8d33faa3a649b02827649f9c76e40edace15 (diff)
downloadgcc-6f93c0089265867666bcf71a659df21a63e0572e.zip
gcc-6f93c0089265867666bcf71a659df21a63e0572e.tar.gz
gcc-6f93c0089265867666bcf71a659df21a63e0572e.tar.bz2
i386.md (rotateinv): New code attr.
* 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. * gcc.target/i386/rotate-1.c: Accept rolb or rorb instruction. From-SVN: r198770
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/config/i386/i386.md57
-rw-r--r--gcc/testsuite/ChangeLog2
-rw-r--r--gcc/testsuite/gcc.target/i386/rotate-1.c2
4 files changed, 45 insertions, 21 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 82b35a1..6739b0d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
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.
+
PR tree-optimization/45216
PR tree-optimization/57157
* tree-ssa-forwprop.c (simplify_rotate): New function.
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index dea5d51..d9179ce 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -761,6 +761,9 @@
;; Base name for insn mnemonic.
(define_code_attr rotate [(rotate "rol") (rotatert "ror")])
+;; Base name for insn mnemonic of rotation in the other direction.
+(define_code_attr rotateinv [(rotate "ror") (rotatert "rol")])
+
;; Mapping of abs neg operators
(define_code_iterator absneg [abs neg])
@@ -9736,11 +9739,15 @@
return "#";
default:
- if (operands[2] == const1_rtx
- && (TARGET_SHIFT1 || optimize_function_for_size_p (cfun)))
- return "<rotate>{<imodesuffix>}\t%0";
- else
- return "<rotate>{<imodesuffix>}\t{%2, %0|%0, %2}";
+ if (TARGET_SHIFT1 || optimize_function_for_size_p (cfun))
+ {
+ if (operands[2] == const1_rtx)
+ return "<rotate>{<imodesuffix>}\t%0";
+ if (CONST_INT_P (operands[2])
+ && INTVAL (operands[2]) == GET_MODE_BITSIZE (<MODE>mode) - 1)
+ return "<rotateinv>{<imodesuffix>}\t%0";
+ }
+ return "<rotate>{<imodesuffix>}\t{%2, %0|%0, %2}";
}
}
[(set_attr "isa" "*,bmi2")
@@ -9802,11 +9809,14 @@
return "#";
default:
- if (operands[2] == const1_rtx
- && (TARGET_SHIFT1 || optimize_function_for_size_p (cfun)))
- return "<rotate>{l}\t%k0";
- else
- return "<rotate>{l}\t{%2, %k0|%k0, %2}";
+ if (TARGET_SHIFT1 || optimize_function_for_size_p (cfun))
+ {
+ if (operands[2] == const1_rtx)
+ return "<rotate>{l}\t%k0";
+ if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 31)
+ return "<rotateinv>{l}\t%k0";
+ }
+ return "<rotate>{l}\t{%2, %k0|%k0, %2}";
}
}
[(set_attr "isa" "*,bmi2")
@@ -9853,11 +9863,15 @@
(clobber (reg:CC FLAGS_REG))]
"ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
{
- if (operands[2] == const1_rtx
- && (TARGET_SHIFT1 || optimize_function_for_size_p (cfun)))
- return "<rotate>{<imodesuffix>}\t%0";
- else
- return "<rotate>{<imodesuffix>}\t{%2, %0|%0, %2}";
+ if (TARGET_SHIFT1 || optimize_function_for_size_p (cfun))
+ {
+ if (operands[2] == const1_rtx)
+ return "<rotate>{<imodesuffix>}\t%0";
+ if (CONST_INT_P (operands[2])
+ && INTVAL (operands[2]) == GET_MODE_BITSIZE (<MODE>mode) - 1)
+ return "<rotateinv>{<imodesuffix>}\t%0";
+ }
+ return "<rotate>{<imodesuffix>}\t{%2, %0|%0, %2}";
}
[(set_attr "type" "rotate")
(set (attr "length_immediate")
@@ -9879,11 +9893,14 @@
|| (operands[1] == const1_rtx
&& TARGET_SHIFT1))"
{
- if (operands[1] == const1_rtx
- && (TARGET_SHIFT1 || optimize_function_for_size_p (cfun)))
- return "<rotate>{b}\t%0";
- else
- return "<rotate>{b}\t{%1, %0|%0, %1}";
+ if (TARGET_SHIFT1 || optimize_function_for_size_p (cfun))
+ {
+ if (operands[2] == const1_rtx)
+ return "<rotate>{b}\t%0";
+ if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 7)
+ return "<rotateinv>{b}\t%0";
+ }
+ return "<rotate>{b}\t{%1, %0|%0, %1}";
}
[(set_attr "type" "rotate1")
(set (attr "length_immediate")
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 19e0a5b..7f29941 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,7 @@
2013-05-10 Jakub Jelinek <jakub@redhat.com>
+ * gcc.target/i386/rotate-1.c: Accept rolb or rorb instruction.
+
PR tree-optimization/45216
PR tree-optimization/57157
* c-c++-common/rotate-1.c: New test.
diff --git a/gcc/testsuite/gcc.target/i386/rotate-1.c b/gcc/testsuite/gcc.target/i386/rotate-1.c
index 23dc2ee..399cbd9 100644
--- a/gcc/testsuite/gcc.target/i386/rotate-1.c
+++ b/gcc/testsuite/gcc.target/i386/rotate-1.c
@@ -13,4 +13,4 @@ main (void)
return c;
}
-/* { dg-final { scan-assembler "rolb" } } */
+/* { dg-final { scan-assembler "ro\[lr]b" } } */