[AArch64] Fix fast-isel of cbz of i1, i8, i16
[oota-llvm.git] / lib / Target / AArch64 / AArch64FastISel.cpp
index 5972d4aad78ba33c6461d9383c3f4bd3142e9cac..a69185854f7286d53907a460c38054ccab0675e3 100644 (file)
@@ -2181,6 +2181,12 @@ bool AArch64FastISel::emitCompareAndBranch(const BranchInst *BI) {
     SrcReg = fastEmitInst_extractsubreg(MVT::i32, SrcReg, SrcIsKill,
                                         AArch64::sub_32);
 
+  if ((BW < 32) && !IsBitTest) {
+    EVT CmpEVT = TLI.getValueType(Ty, true);
+    SrcReg =
+        emitIntExt(CmpEVT.getSimpleVT(), SrcReg, MVT::i32, /*isZExt*/ true);
+  }
+
   // Emit the combined compare and branch instruction.
   SrcReg = constrainOperandRegClass(II, SrcReg,  II.getNumDefs());
   MachineInstrBuilder MIB =