[llvm-dev] Canonical way to handle zero registers?

Daniel Sanders via llvm-dev llvm-dev at lists.llvm.org
Tue Jan 2 08:28:47 PST 2018

Hi Sean,

Just to give the GlobalISel perspective on this, GlobalISel supports the declaration of a zero register in the register class like so:
	def GPR32z : RegisterOperand<GPR32> {
	  let GIZeroRegister = WZR;
With that definition, the tablegen-erated ISel code will try to replace will try to replace 'G_CONSTANT s32 0' with WZR whenever the operand is specified as GPR32z.

> On 21 Dec 2017, at 21:22, Sean Silva via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> I looked around the codebase and didn't see anything that obviously looked like the natural place to turn constant zero immediates into zero-registers (i.e. registers that always return zero when read). Right now we are expanding them in ISelLowering::LowerOperation but that seems too early.
> The specific issue I'm hitting is that we have a register that reads as -1 and so when we replace -1 too early with this register, the standard "not" pattern (xor x, -1) will fail to match to "not".
> Thanks,
> Sean Silva
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

More information about the llvm-dev mailing list