Skip to content

Commit 2f03c19

Browse files
authored
Merge pull request #3013 from WojciechMula/simplify-asm
Simplify HUF_decompress4X2_usingDTable_internal_bmi2_asm_loop
2 parents 4a35912 + e74ca79 commit 2f03c19

File tree

1 file changed

+15
-26
lines changed

1 file changed

+15
-26
lines changed

lib/decompress/huf_decompress_amd64.S

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -427,41 +427,30 @@ HUF_decompress4X2_usingDTable_internal_bmi2_asm_loop:
427427
/* r15 = (ip0 - ilimit) / 7 */
428428
movq %rdx, %r15
429429

430-
movabsq $-3689348814741910323, %rdx
431-
movq 8(%rsp), %rax /* rax = oend0 */
432-
subq %op0, %rax /* rax = oend0 - op0 */
433-
mulq %rdx
434-
shrq $3, %rdx /* rdx = rax / 10 */
435-
436-
/* r15 = min(%rdx, %r15) */
437-
cmpq %rdx, %r15
438-
cmova %rdx, %r15
430+
/* r15 = min(r15, min(oend0 - op0, oend1 - op1, oend2 - op2, oend3 - op3) / 10) */
431+
movq 8(%rsp), %rax /* rax = oend0 */
432+
subq %op0, %rax /* rax = oend0 - op0 */
433+
movq 16(%rsp), %rdx /* rdx = oend1 */
434+
subq %op1, %rdx /* rdx = oend1 - op1 */
439435

440-
movabsq $-3689348814741910323, %rdx
441-
movq 16(%rsp), %rax /* rax = oend1 */
442-
subq %op1, %rax /* rax = oend1 - op1 */
443-
mulq %rdx
444-
shrq $3, %rdx /* rdx = rax / 10 */
445-
446-
/* r15 = min(%rdx, %r15) */
447-
cmpq %rdx, %r15
448-
cmova %rdx, %r15
436+
cmpq %rax, %rdx
437+
cmova %rax, %rdx /* rdx = min(%rdx, %rax) */
449438

450-
movabsq $-3689348814741910323, %rdx
451439
movq 24(%rsp), %rax /* rax = oend2 */
452440
subq %op2, %rax /* rax = oend2 - op2 */
453-
mulq %rdx
454-
shrq $3, %rdx /* rdx = rax / 10 */
455441

456-
/* r15 = min(%rdx, %r15) */
457-
cmpq %rdx, %r15
458-
cmova %rdx, %r15
442+
cmpq %rax, %rdx
443+
cmova %rax, %rdx /* rdx = min(%rdx, %rax) */
459444

460-
movabsq $-3689348814741910323, %rdx
461445
movq 32(%rsp), %rax /* rax = oend3 */
462446
subq %op3, %rax /* rax = oend3 - op3 */
447+
448+
cmpq %rax, %rdx
449+
cmova %rax, %rdx /* rdx = min(%rdx, %rax) */
450+
451+
movabsq $-3689348814741910323, %rax
463452
mulq %rdx
464-
shrq $3, %rdx /* rdx = rax / 10 */
453+
shrq $3, %rdx /* rdx = rdx / 10 */
465454

466455
/* r15 = min(%rdx, %r15) */
467456
cmpq %rdx, %r15

0 commit comments

Comments
 (0)