diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp index d95fc8cfbcf55..027e4ee7159b4 100644 --- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp @@ -7830,9 +7830,7 @@ bool CombinerHelper::matchSuboCarryOut(const MachineInstr &MI, case ConstantRange::OverflowResult::AlwaysOverflowsHigh: { MatchInfo = [=](MachineIRBuilder &B) { B.buildSub(Dst, LHS, RHS); - B.buildConstant(Carry, getICmpTrueVal(getTargetLowering(), - /*isVector=*/CarryTy.isVector(), - /*isFP=*/false)); + B.buildConstant(Carry, 1); }; return true; } @@ -7855,9 +7853,7 @@ bool CombinerHelper::matchSuboCarryOut(const MachineInstr &MI, case ConstantRange::OverflowResult::AlwaysOverflowsHigh: { MatchInfo = [=](MachineIRBuilder &B) { B.buildSub(Dst, LHS, RHS); - B.buildConstant(Carry, getICmpTrueVal(getTargetLowering(), - /*isVector=*/CarryTy.isVector(), - /*isFP=*/false)); + B.buildConstant(Carry, 1); }; return true; } diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/combine-overflow.mir b/llvm/test/CodeGen/AArch64/GlobalISel/combine-overflow.mir index 20cba54923548..8f24ee76f82b3 100644 --- a/llvm/test/CodeGen/AArch64/GlobalISel/combine-overflow.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/combine-overflow.mir @@ -277,3 +277,26 @@ body: | $q1 = COPY %o_wide RET_ReallyLR implicit $w0 ... +--- +name: usub_may_carry_non_const +body: | + bb.0: + liveins: $w0, $w1 + ; CHECK-LABEL: name: usub_may_carry_non_const + ; CHECK: liveins: $w0, $w1 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0 + ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $w0 + ; CHECK-NEXT: %sub:_(s32), %o:_(s1) = G_USUBO [[COPY]], [[COPY1]] + ; CHECK-NEXT: %o_wide:_(s32) = G_ZEXT %o(s1) + ; CHECK-NEXT: $w0 = COPY %sub(s32) + ; CHECK-NEXT: $w1 = COPY %o_wide(s32) + ; CHECK-NEXT: RET_ReallyLR implicit $w0 + %0:_(s32) = COPY $w0 + %1:_(s32) = COPY $w0 + %sub:_(s32), %o:_(s1) = G_USUBO %0, %1 + %o_wide:_(s32) = G_ZEXT %o(s1) + $w0 = COPY %sub(s32) + $w1 = COPY %o_wide + RET_ReallyLR implicit $w0 +...