Skip to content

[Patch] x86: SETcc/TEST/SETcc -> SETcc/SETcc optimisation

Original Reporter info from Mantis: CuriousKit @CuriousKit
  • Reporter name: J. Gareth Moreton

Description:

This patch extends the SETcc/TEST/Jcc optimisation to also work with SETcc instead of just Jcc.

Steps to reproduce:

Apply patch and confirm correct compilation.

Additional information:

This particular optimisation only appears a few times in the RTL, but the addition to the compiler source is very cheap.

In Sysutils, before:

	...
	btl	%eax,TC_$SYSTEM_$$_ALLOWDIRECTORYSEPARATORS(%rip)
	setcb	%al
	testb	%al,%al
# Peephole Optimization: J(c)Mov1JmpMov0 -> Set(~c) (partial)
	setneb	%al
	ret
.Lj1274:
	...

After:

	...
	btl	%eax,TC_$SYSTEM_$$_ALLOWDIRECTORYSEPARATORS(%rip)
# Peephole Optimization: J(c)Mov1JmpMov0 -> Set(~c) (partial)
# Peephole Optimization: SETcc/TEST/SETcc -> SETcc
	setcb	%al
	ret
.Lj1274:
	...

Mantis conversion info:

  • Mantis ID: 39271
  • OS: Microsoft Windows
  • OS Build: 10 Home
  • Build: r49621
  • Platform: i386 and x86_64
  • Version: 3.3.1
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information