Skip to content

Commit debdaaa

Browse files
authored
Merge branch 'main' into main
2 parents 8af4a17 + 8a62104 commit debdaaa

File tree

5 files changed

+390
-2
lines changed

5 files changed

+390
-2
lines changed

.github/workflows/docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ jobs:
106106
with:
107107
python-version: '3.11'
108108
cache: 'pip'
109-
cache-dependency-path: 'llvm/docs/requirements.txt'
109+
cache-dependency-path: 'llvm/docs/requirements-hashed.txt'
110110
- name: Install python dependencies
111-
run: pip install -r llvm/docs/requirements.txt
111+
run: pip install -r llvm/docs/requirements-hashed.txt
112112
- name: Install system dependencies
113113
run: |
114114
sudo apt-get update

llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,43 @@ static bool isIntrinsicExpansion(Function &F) {
6767
case Intrinsic::dx_sign:
6868
case Intrinsic::dx_step:
6969
case Intrinsic::dx_radians:
70+
case Intrinsic::vector_reduce_add:
71+
case Intrinsic::vector_reduce_fadd:
7072
return true;
7173
}
7274
return false;
7375
}
76+
static Value *expandVecReduceAdd(CallInst *Orig, Intrinsic::ID IntrinsicId) {
77+
assert(IntrinsicId == Intrinsic::vector_reduce_add ||
78+
IntrinsicId == Intrinsic::vector_reduce_fadd);
79+
80+
IRBuilder<> Builder(Orig);
81+
bool IsFAdd = (IntrinsicId == Intrinsic::vector_reduce_fadd);
82+
83+
Value *X = Orig->getOperand(IsFAdd ? 1 : 0);
84+
Type *Ty = X->getType();
85+
auto *XVec = dyn_cast<FixedVectorType>(Ty);
86+
unsigned XVecSize = XVec->getNumElements();
87+
Value *Sum = Builder.CreateExtractElement(X, static_cast<uint64_t>(0));
88+
89+
// Handle the initial start value for floating-point addition.
90+
if (IsFAdd) {
91+
Constant *StartValue = dyn_cast<Constant>(Orig->getOperand(0));
92+
if (StartValue && !StartValue->isZeroValue())
93+
Sum = Builder.CreateFAdd(Sum, StartValue);
94+
}
95+
96+
// Accumulate the remaining vector elements.
97+
for (unsigned I = 1; I < XVecSize; I++) {
98+
Value *Elt = Builder.CreateExtractElement(X, I);
99+
if (IsFAdd)
100+
Sum = Builder.CreateFAdd(Sum, Elt);
101+
else
102+
Sum = Builder.CreateAdd(Sum, Elt);
103+
}
104+
105+
return Sum;
106+
}
74107

75108
static Value *expandAbs(CallInst *Orig) {
76109
Value *X = Orig->getOperand(0);
@@ -580,6 +613,10 @@ static bool expandIntrinsic(Function &F, CallInst *Orig) {
580613
case Intrinsic::dx_radians:
581614
Result = expandRadiansIntrinsic(Orig);
582615
break;
616+
case Intrinsic::vector_reduce_add:
617+
case Intrinsic::vector_reduce_fadd:
618+
Result = expandVecReduceAdd(Orig, IntrinsicId);
619+
break;
583620
}
584621
if (Result) {
585622
Orig->replaceAllUsesWith(Result);

llvm/lib/Target/RISCV/RISCVInstrInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2451,6 +2451,10 @@ bool RISCVInstrInfo::verifyInstruction(const MachineInstr &MI,
24512451
if (OpType >= RISCVOp::OPERAND_FIRST_RISCV_IMM &&
24522452
OpType <= RISCVOp::OPERAND_LAST_RISCV_IMM) {
24532453
const MachineOperand &MO = MI.getOperand(Index);
2454+
if (MO.isReg()) {
2455+
ErrInfo = "Expected a non-register operand.";
2456+
return false;
2457+
}
24542458
if (MO.isImm()) {
24552459
int64_t Imm = MO.getImm();
24562460
bool Ok;

0 commit comments

Comments
 (0)