Bug 231159

Summary: [JSC][ARMv7] Improve instruction selection in MacroAssembler
Product: WebKit Reporter: Geza Lore <glore>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: guijemont, mikhail, webkit-bug-importer, xan.lopez
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Geza Lore 2021-10-04 02:29:12 PDT
I have spotted some improvement opportunities in MacroAssemblerARMv7 for better instruction selection for some macros. What shows up most often in the disassembly ('ip' is 'r12'):

mvn ip, #8
and r0, r0, ip

This is an 8-byte sequence which is equivalent to the following 2-byte instruction:

bic r0, #8


similarly:

mvn ip, #7
add r0, r0, ip

should be:

sub r0, r0, #8

A review of the disassembly would likely yield more examples of similar sequences where an immediate can be encoded cheaper using an alternative instruction.
Comment 1 Guillaume Emont 2021-10-06 08:53:32 PDT
(In reply to Geza Lore from comment #0)
> I have spotted some improvement opportunities in MacroAssemblerARMv7 for
> better instruction selection for some macros. What shows up most often in
> the disassembly ('ip' is 'r12'):
> 
> mvn ip, #8
> and r0, r0, ip
> 
> This is an 8-byte sequence which is equivalent to the following 2-byte
> instruction:
> 
> bic r0, #8
> 
> 
> similarly:
> 
> mvn ip, #7
> add r0, r0, ip
> 
> should be:
> 
> sub r0, r0, #8
> 
> A review of the disassembly would likely yield more examples of similar
> sequences where an immediate can be encoded cheaper using an alternative
> instruction.

Would any of this change the minimal version of the instruction set that we support? (not that I have it very clear in my mind what is our minimum currently).
Comment 2 Geza Lore 2021-10-06 09:32:00 PDT
Not these. BIC and SUB are as old as AND and ADD.
Comment 3 Radar WebKit Bug Importer 2021-10-11 02:30:20 PDT
<rdar://problem/84091839>
Comment 4 Geza Lore 2021-11-30 07:21:03 PST
Note https://bugs.webkit.org/show_bug.cgi?id=233474 implements the most frequent case of the mentioned add/sub exchange.
Comment 5 Geza Lore 2022-03-24 03:34:21 PDT
These have now been implemented in various patches