[GlobalISel] Fix buildZExtInReg creating new register.
authorVang Thao <Vang.Thao@amd.com>
Tue, 4 May 2021 23:43:07 +0000 (16:43 -0700)
committerVang Thao <Vang.Thao@amd.com>
Wed, 5 May 2021 15:19:52 +0000 (08:19 -0700)
Fix a bug where buildZExtInReg will create and use a new register instead of using the register from parameter DstOp Res.

Reviewed By: arsenm, foad

Differential Revision: https://reviews.llvm.org/D101871

llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp

index bde442a..1f86bfa 100644 (file)
@@ -492,7 +492,7 @@ MachineInstrBuilder MachineIRBuilder::buildZExtInReg(const DstOp &Res,
   LLT ResTy = Res.getLLTTy(*getMRI());
   auto Mask = buildConstant(
       ResTy, APInt::getLowBitsSet(ResTy.getScalarSizeInBits(), ImmOp));
-  return buildAnd(ResTy, Op, Mask);
+  return buildAnd(Res, Op, Mask);
 }
 
 MachineInstrBuilder MachineIRBuilder::buildCast(const DstOp &Dst,