8203628: Optimize (masked) byte memory comparisons on x86

Reviewed-by: adinn, vlivanov, jrose
This commit is contained in:
Aleksey Shipilev 2018-05-28 09:05:43 +02:00
parent 080269eb20
commit e1c94920e5

View File

@ -2980,6 +2980,16 @@ operand immI8()
interface(CONST_INTER);
%}
operand immU8()
%{
predicate((0 <= n->get_int()) && (n->get_int() <= 255));
match(ConI);
op_cost(5);
format %{ %}
interface(CONST_INTER);
%}
operand immI16()
%{
predicate((-32768 <= n->get_int()) && (n->get_int() <= 32767));
@ -11597,6 +11607,46 @@ instruct testUL_reg(rFlagsRegU cr, rRegL src, immL0 zero)
ins_pipe(ialu_cr_reg_imm);
%}
instruct compUB_mem_imm(rFlagsReg cr, memory mem, immU8 imm)
%{
match(Set cr (CmpI (LoadUB mem) imm));
ins_cost(125);
format %{ "cmpb $mem, $imm" %}
ins_encode %{ __ cmpb($mem$$Address, $imm$$constant); %}
ins_pipe(ialu_cr_reg_mem);
%}
instruct compB_mem_imm(rFlagsReg cr, memory mem, immI8 imm)
%{
match(Set cr (CmpI (LoadB mem) imm));
ins_cost(125);
format %{ "cmpb $mem, $imm" %}
ins_encode %{ __ cmpb($mem$$Address, $imm$$constant); %}
ins_pipe(ialu_cr_reg_mem);
%}
instruct testUB_mem_imm(rFlagsReg cr, memory mem, immU8 imm, immI0 zero)
%{
match(Set cr (CmpI (AndI (LoadUB mem) imm) zero));
ins_cost(125);
format %{ "testb $mem, $imm" %}
ins_encode %{ __ testb($mem$$Address, $imm$$constant); %}
ins_pipe(ialu_cr_reg_mem);
%}
instruct testB_mem_imm(rFlagsReg cr, memory mem, immI8 imm, immI0 zero)
%{
match(Set cr (CmpI (AndI (LoadB mem) imm) zero));
ins_cost(125);
format %{ "testb $mem, $imm" %}
ins_encode %{ __ testb($mem$$Address, $imm$$constant); %}
ins_pipe(ialu_cr_reg_mem);
%}
//----------Max and Min--------------------------------------------------------
// Min Instructions