[9] RFR(S): 8075136: Unnecessary sign extension for byte array access

Andrew Dinn adinn at redhat.com
Wed Mar 18 11:45:02 UTC 2015

On 18/03/15 11:38, Andrew Haley wrote:
> On 03/18/2015 11:19 AM, Tobias Hartmann wrote:
>> . . .
>> Yes, it's because we have no operand for the indirect-with-offset
>> (no scaling) case and therefore it is matched to 'addP_reg_reg_ext'.
>> For this reason I added the two new operands indIndexOffsetI2L and
>> indIndexOffsetI2LN. But even with those operands, it only works if
>> we reduce their cost below INSN_COST. Otherwise, 'AddP (AddP reg
>> (ConvI2L ireg)) off' is matched to 'addP_reg_reg_ext' (cost
> Aha!  That's the bug.  'addP_reg_reg_ext' should be 2*INSN_COST,
> along with all the ALU extend and/or shift instructions.  My
> bad, probably.

Ok, seems like Andrew Haley has pretty much answered this. So, fixing
the addP_reg_reg_ext rule should be all that is needed.

There is still one lingering question Andrew did not address:

>> I still wonder if it would pay off to remove the sign extension
>> completely (as we do on x86)?

I don't know if this actually matters. I don't have any evidence to
suggest that sxtw is going to cost any more than uxtw. Perhaps andrew
Haley can comment on this?


Andrew Dinn
Senior Principal Software Engineer
Red Hat UK Ltd
Registered in UK and Wales under Company Registration No. 3798903
Directors: Michael Cunningham (USA), Matt Parson (USA), Charlie Peters
(USA), Michael O'Neill (Ireland)

More information about the hotspot-compiler-dev mailing list