Skip to content

Commit d2f25e5

Browse files
committed
[LegalizeTypes] Avoid creating an unused node in ExpandIntRes_ADDSUB. NFC
The Hi result is sometimes calculated a different way and this node goes unused. Defer creation until we know for sure it is neeeded. The test changes is because the node creation order changed the names in the debug output.
1 parent ae5f1a7 commit d2f25e5

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3496,7 +3496,6 @@ void DAGTypeLegalizer::ExpandIntRes_ADDSUB(SDNode *N,
34963496

34973497
if (N->getOpcode() == ISD::ADD) {
34983498
Lo = DAG.getNode(ISD::ADD, dl, NVT, LoOps);
3499-
Hi = DAG.getNode(ISD::ADD, dl, NVT, ArrayRef(HiOps, 2));
35003499
SDValue Cmp;
35013500
// Special case: X+1 has a carry out if X+1==0. This may reduce the live
35023501
// range of X. We assume comparing with 0 is cheap.
@@ -3521,10 +3520,12 @@ void DAGTypeLegalizer::ExpandIntRes_ADDSUB(SDNode *N,
35213520
Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
35223521
DAG.getConstant(0, dl, NVT));
35233522

3524-
if (isAllOnesConstant(LoOps[1]) && isAllOnesConstant(HiOps[1]))
3523+
if (isAllOnesConstant(LoOps[1]) && isAllOnesConstant(HiOps[1])) {
35253524
Hi = DAG.getNode(ISD::SUB, dl, NVT, HiOps[0], Carry);
3526-
else
3525+
} else {
3526+
Hi = DAG.getNode(ISD::ADD, dl, NVT, ArrayRef(HiOps, 2));
35273527
Hi = DAG.getNode(ISD::ADD, dl, NVT, Hi, Carry);
3528+
}
35283529
} else {
35293530
Lo = DAG.getNode(ISD::SUB, dl, NVT, LoOps);
35303531
Hi = DAG.getNode(ISD::SUB, dl, NVT, ArrayRef(HiOps, 2));

llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/lanai_isel.ll.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ define i64 @i64_test(i64 %i) nounwind readnone {
1212
; CHECK-NEXT: t24: i32 = ADD_R t5, t22, TargetConstant:i32<0>
1313
; CHECK-NEXT: t3: i32,ch = LDW_RI<Mem:(load (s32) from %fixed-stack.1, align 8)> TargetFrameIndex:i32<-1>, TargetConstant:i32<0>, TargetConstant:i32<0>, t0
1414
; CHECK-NEXT: t19: i32,ch = LDW_RI<Mem:(dereferenceable load (s32) from %ir.loc, align 8)> TargetFrameIndex:i32<0>, TargetConstant:i32<0>, TargetConstant:i32<0>, t0
15-
; CHECK-NEXT: t25: i32 = ADD_R t3, t19, TargetConstant:i32<0>
15+
; CHECK-NEXT: t27: i32 = ADD_R t3, t19, TargetConstant:i32<0>
1616
; CHECK-NEXT: t30: i32,glue = SFSUB_F_RR t24, t5
1717
; CHECK-NEXT: t31: i32 = SCC TargetConstant:i32<4>, t30:1
18-
; CHECK-NEXT: t28: i32 = ADD_R t25, t31, TargetConstant:i32<0>
18+
; CHECK-NEXT: t28: i32 = ADD_R t27, t31, TargetConstant:i32<0>
1919
; CHECK-NEXT: t15: ch,glue = CopyToReg t0, Register:i32 $rv, t28
2020
; CHECK-NEXT: t17: ch,glue = CopyToReg t15, Register:i32 $r9, t24, t15:1
2121
; CHECK-NEXT: t18: ch = RET Register:i32 $rv, Register:i32 $r9, t17, t17:1

0 commit comments

Comments
 (0)