Eliding of slice range checking

kinke kinke at gmx.net
Wed Oct 23 13:51:19 UTC 2019


On Wednesday, 23 October 2019 at 13:08:34 UTC, Per Nordlöw wrote:
> The ASM- and IR-output from the following code is pretty messy 
> for

You call this messy?!

cmpq	%rdi, %rdx
	jae	.LBB0_2
	xorl	%eax, %eax
	retq
.LBB0_2:
	movq	%rdi, %rax
	testq	%rdi, %rdi
	je	.LBB0_3
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	%rcx, %rdi
	movq	%rax, %rdx
	callq	memcmp at PLT
	testl	%eax, %eax
	sete	%al
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	retq
.LBB0_3:
	movb	$1, %al
	retq

Anyway, clearly no bounds checks, LLVM's optimizer works as it 
should.


More information about the Digitalmars-d-learn mailing list