Skip to content

Commit 445dd43

Browse files
author
Zaara Syeda
committed
Address review comments
1 parent 86a2ff1 commit 445dd43

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

llvm/lib/Target/PowerPC/PPCISelLowering.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11973,8 +11973,15 @@ SDValue PPCTargetLowering::LowerUaddo(SDValue Op, SelectionDAG &DAG) const {
1197311973
// Default to target independent lowering if there is a logical user of the
1197411974
// carry-bit.
1197511975
for (SDNode *U : Op->uses()) {
11976-
if (U->getOpcode() == ISD::SELECT || ISD::isBitwiseLogicOp(U->getOpcode()))
11976+
if (U->getOpcode() == ISD::SELECT)
1197711977
return SDValue();
11978+
if (ISD::isBitwiseLogicOp(U->getOpcode())) {
11979+
for (unsigned i = 0, ie = U->getNumOperands(); i != ie; ++i) {
11980+
if (U->getOperand(i).getOpcode() != ISD::UADDO &&
11981+
U->getOperand(i).getOpcode() != ISD::MERGE_VALUES)
11982+
return SDValue();
11983+
}
11984+
}
1197811985
}
1197911986
SDValue LHS = Op.getOperand(0);
1198011987
SDValue RHS = Op.getOperand(1);
@@ -12006,8 +12013,7 @@ SDValue PPCTargetLowering::LowerUaddo(SDValue Op, SelectionDAG &DAG) const {
1200612013
SDValue PPCTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
1200712014
switch (Op.getOpcode()) {
1200812015
default: llvm_unreachable("Wasn't expecting to be able to lower this!");
12009-
case ISD::UADDO:
12010-
return LowerUaddo(Op, DAG);
12016+
case ISD::UADDO: return LowerUaddo(Op, DAG);
1201112017
case ISD::FPOW: return lowerPow(Op, DAG);
1201212018
case ISD::FSIN: return lowerSin(Op, DAG);
1201312019
case ISD::FCOS: return lowerCos(Op, DAG);

llvm/test/CodeGen/PowerPC/uaddo-64.ll

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,27 @@ entry:
3636
store i64 %2, ptr %ovf, align 8
3737
ret i1 %1
3838
}
39+
40+
define noundef i64 @addWithCarryIn (i64 noundef %a, i64 noundef %b, i64 noundef %c, ptr nocapture noundef writeonly %ovf) {
41+
; CHECK-LABEL: addWithCarryIn:
42+
; CHECK: # %bb.0: # %entry
43+
; CHECK-NEXT: li 7, 0
44+
; CHECK-NEXT: addc 3, 3, 4
45+
; CHECK-NEXT: addze 4, 7
46+
; CHECK-NEXT: addc 3, 3, 5
47+
; CHECK-NEXT: addze 5, 7
48+
; CHECK-NEXT: or 4, 4, 5
49+
; CHECK-NEXT: std 4, 0(6)
50+
; CHECK-NEXT: blr
51+
entry:
52+
%0 = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %a, i64 %b)
53+
%1 = extractvalue { i64, i1 } %0, 1
54+
%2 = extractvalue { i64, i1 } %0, 0
55+
%3 = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %2, i64 %c)
56+
%4 = extractvalue { i64, i1 } %3, 1
57+
%5 = extractvalue { i64, i1 } %3, 0
58+
%6 = or i1 %1, %4
59+
%7 = zext i1 %6 to i64
60+
store i64 %7, ptr %ovf, align 8
61+
ret i64 %5
62+
}

0 commit comments

Comments
 (0)