Skip to content

Commit a770dd2

Browse files
committed
address pr comments
1 parent 5e05939 commit a770dd2

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,6 @@ static Value *expandVecReduceAdd(CallInst *Orig, Intrinsic::ID IntrinsicId) {
8080
IRBuilder<> Builder(Orig);
8181
bool IsFAdd = (IntrinsicId == Intrinsic::vector_reduce_fadd);
8282

83-
// Define the addition operation based on the intrinsic ID.
84-
auto AddOp = [&Builder, IsFAdd](Value *Sum, Value *Elt) {
85-
return IsFAdd ? Builder.CreateFAdd(Sum, Elt) : Builder.CreateAdd(Sum, Elt);
86-
};
87-
8883
Value *X = Orig->getOperand(IsFAdd ? 1 : 0);
8984
Type *Ty = X->getType();
9085
auto *XVec = dyn_cast<FixedVectorType>(Ty);
@@ -93,16 +88,18 @@ static Value *expandVecReduceAdd(CallInst *Orig, Intrinsic::ID IntrinsicId) {
9388

9489
// Handle the initial start value for floating-point addition.
9590
if (IsFAdd) {
96-
llvm::Constant *StartValue =
97-
llvm::dyn_cast<llvm::Constant>(Orig->getOperand(0));
91+
Constant *StartValue = dyn_cast<Constant>(Orig->getOperand(0));
9892
if (StartValue && !StartValue->isZeroValue())
9993
Sum = Builder.CreateFAdd(Sum, StartValue);
10094
}
10195

10296
// Accumulate the remaining vector elements.
10397
for (unsigned I = 1; I < XVecSize; I++) {
10498
Value *Elt = Builder.CreateExtractElement(X, I);
105-
Sum = AddOp(Sum, Elt);
99+
if (IsFAdd)
100+
Sum = Builder.CreateFAdd(Sum, Elt);
101+
else
102+
Sum = Builder.CreateAdd(Sum, Elt);
106103
}
107104

108105
return Sum;

0 commit comments

Comments
 (0)