forked from jacobly0/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Currently, comparing to zero uses __*cmpzero, and checking for only equality between integers uses __*cmpu or __*cmps. Slightly faster routines that only output to the Z flag could be used instead, so I am proposing adding __*equzero and __*cmpeq.
__*cmpzero : Z P
__*equzero : Z
__*cmpu : Z C
__*cmps : Z P V
__*cmpeq : Z
__*equzeroand__*cmpeqcan be emitted instead of__*cmpzeroand__*cmp(u/s)when only the Z flag (or equality) is needed.__*equzerocan be aliased to__*cmpzerowithout issue.__*cmpeqcan be aliased to__*cmpuor__*cmpswithout issue.
For the most part, this is mainly a speed optimization. However, adding __llequzero and __i48equzero could be a beneficial size optimization, since the sign flag is basically never used from __llcmpzero and __i48cmpzero. So we could link just the smaller __llequzero and __i48equzero routines.
; 21 bytes
__llcmpzero:
inc b
dec b
ret nz
inc.s bc
dec c
jr nz, .p_nz
or a, a
sbc hl, bc
jr nz, .p_nz
sbc hl, de
ret z
add hl, de
.p_nz:
inc b
ld b, 0
ret
; 15 bytes
__llequzero:
inc b
dec b
ret nz
inc c
dec c
ret nz
add hl, bc
or a, a
sbc hl, bc
ret nz
sbc hl, de
add hl, de
retReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request