diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp index a1cb74f43e6050..2fa9e46eae506a 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp @@ -3496,7 +3496,6 @@ void DAGTypeLegalizer::ExpandIntRes_ADDSUB(SDNode *N, if (N->getOpcode() == ISD::ADD) { Lo = DAG.getNode(ISD::ADD, dl, NVT, LoOps); - Hi = DAG.getNode(ISD::ADD, dl, NVT, ArrayRef(HiOps, 2)); SDValue Cmp; // Special case: X+1 has a carry out if X+1==0. This may reduce the live // range of X. We assume comparing with 0 is cheap. @@ -3521,10 +3520,12 @@ void DAGTypeLegalizer::ExpandIntRes_ADDSUB(SDNode *N, Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT), DAG.getConstant(0, dl, NVT)); - if (isAllOnesConstant(LoOps[1]) && isAllOnesConstant(HiOps[1])) + if (isAllOnesConstant(LoOps[1]) && isAllOnesConstant(HiOps[1])) { Hi = DAG.getNode(ISD::SUB, dl, NVT, HiOps[0], Carry); - else + } else { + Hi = DAG.getNode(ISD::ADD, dl, NVT, ArrayRef(HiOps, 2)); Hi = DAG.getNode(ISD::ADD, dl, NVT, Hi, Carry); + } } else { Lo = DAG.getNode(ISD::SUB, dl, NVT, LoOps); Hi = DAG.getNode(ISD::SUB, dl, NVT, ArrayRef(HiOps, 2)); diff --git a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/lanai_isel.ll.expected b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/lanai_isel.ll.expected index 71e82eca6c3e3f..936efa378c1a4f 100644 --- a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/lanai_isel.ll.expected +++ b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/lanai_isel.ll.expected @@ -12,10 +12,10 @@ define i64 @i64_test(i64 %i) nounwind readnone { ; CHECK-NEXT: t24: i32 = ADD_R t5, t22, TargetConstant:i32<0> ; CHECK-NEXT: t3: i32,ch = LDW_RI TargetFrameIndex:i32<-1>, TargetConstant:i32<0>, TargetConstant:i32<0>, t0 ; CHECK-NEXT: t19: i32,ch = LDW_RI TargetFrameIndex:i32<0>, TargetConstant:i32<0>, TargetConstant:i32<0>, t0 -; CHECK-NEXT: t25: i32 = ADD_R t3, t19, TargetConstant:i32<0> +; CHECK-NEXT: t27: i32 = ADD_R t3, t19, TargetConstant:i32<0> ; CHECK-NEXT: t30: i32,glue = SFSUB_F_RR t24, t5 ; CHECK-NEXT: t31: i32 = SCC TargetConstant:i32<4>, t30:1 -; CHECK-NEXT: t28: i32 = ADD_R t25, t31, TargetConstant:i32<0> +; CHECK-NEXT: t28: i32 = ADD_R t27, t31, TargetConstant:i32<0> ; CHECK-NEXT: t15: ch,glue = CopyToReg t0, Register:i32 $rv, t28 ; CHECK-NEXT: t17: ch,glue = CopyToReg t15, Register:i32 $r9, t24, t15:1 ; CHECK-NEXT: t18: ch = RET Register:i32 $rv, Register:i32 $r9, t17, t17:1