6752257: Use NOT instead of XOR -1 on x86
Summary: add match rule for xor -1
Reviewed-by: never, kvn
--- a/hotspot/src/cpu/x86/vm/x86_32.ad Mon Oct 06 13:11:32 2008 -0700
+++ b/hotspot/src/cpu/x86/vm/x86_32.ad Fri Oct 10 09:47:56 2008 -0700
@@ -4810,6 +4810,16 @@
interface(CONST_INTER);
%}
+// Long Immediate zero
+operand immL_M1() %{
+ predicate( n->get_long() == -1L );
+ match(ConL);
+ op_cost(0);
+
+ format %{ %}
+ interface(CONST_INTER);
+%}
+
// Long immediate from 0 to 127.
// Used for a shorter form of long mul by 10.
operand immL_127() %{
@@ -8621,6 +8631,18 @@
ins_pipe( ialu_reg_reg );
%}
+// Xor Register with Immediate -1
+instruct xorI_eReg_im1(eRegI dst, immI_M1 imm) %{
+ match(Set dst (XorI dst imm));
+
+ size(2);
+ format %{ "NOT $dst" %}
+ ins_encode %{
+ __ notl($dst$$Register);
+ %}
+ ins_pipe( ialu_reg );
+%}
+
// Xor Register with Immediate
instruct xorI_eReg_imm(eRegI dst, immI src, eFlagsReg cr) %{
match(Set dst (XorI dst src));
@@ -8938,6 +8960,18 @@
ins_pipe( ialu_reg_reg_long );
%}
+// Xor Long Register with Immediate -1
+instruct xorl_eReg_im1(eRegL dst, immL_M1 imm) %{
+ match(Set dst (XorL dst imm));
+ format %{ "NOT $dst.lo\n\t"
+ "NOT $dst.hi" %}
+ ins_encode %{
+ __ notl($dst$$Register);
+ __ notl(HIGH_FROM_LOW($dst$$Register));
+ %}
+ ins_pipe( ialu_reg_long );
+%}
+
// Xor Long Register with Immediate
instruct xorl_eReg_imm(eRegL dst, immL src, eFlagsReg cr) %{
match(Set dst (XorL dst src));
--- a/hotspot/src/cpu/x86/vm/x86_64.ad Mon Oct 06 13:11:32 2008 -0700
+++ b/hotspot/src/cpu/x86/vm/x86_64.ad Fri Oct 10 09:47:56 2008 -0700
@@ -9309,6 +9309,17 @@
ins_pipe(ialu_reg_reg);
%}
+// Xor Register with Immediate -1
+instruct xorI_rReg_im1(rRegI dst, immI_M1 imm) %{
+ match(Set dst (XorI dst imm));
+
+ format %{ "not $dst" %}
+ ins_encode %{
+ __ notl($dst$$Register);
+ %}
+ ins_pipe(ialu_reg);
+%}
+
// Xor Register with Immediate
instruct xorI_rReg_imm(rRegI dst, immI src, rFlagsReg cr)
%{
@@ -9529,6 +9540,17 @@
ins_pipe(ialu_reg_reg);
%}
+// Xor Register with Immediate -1
+instruct xorL_rReg_im1(rRegL dst, immL_M1 imm) %{
+ match(Set dst (XorL dst imm));
+
+ format %{ "notq $dst" %}
+ ins_encode %{
+ __ notq($dst$$Register);
+ %}
+ ins_pipe(ialu_reg);
+%}
+
// Xor Register with Immediate
instruct xorL_rReg_imm(rRegL dst, immL32 src, rFlagsReg cr)
%{