Skip to content

Commit 586ecd7

Browse files
authored
AMDGPU: Relax vector restriction for rootn libcall folds (#92594)
We could try harder for nonsplat vectors but probably not worth the effort.
1 parent 9def85f commit 586ecd7

File tree

2 files changed

+54
-67
lines changed

2 files changed

+54
-67
lines changed

llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,17 +1156,13 @@ bool AMDGPULibCalls::fold_pow(FPMathOperator *FPOp, IRBuilder<> &B,
11561156

11571157
bool AMDGPULibCalls::fold_rootn(FPMathOperator *FPOp, IRBuilder<> &B,
11581158
const FuncInfo &FInfo) {
1159-
// skip vector function
1160-
if (getVecSize(FInfo) != 1)
1161-
return false;
1162-
11631159
Value *opr0 = FPOp->getOperand(0);
11641160
Value *opr1 = FPOp->getOperand(1);
11651161

1166-
ConstantInt *CINT = dyn_cast<ConstantInt>(opr1);
1167-
if (!CINT) {
1162+
const APInt *CINT = nullptr;
1163+
if (!match(opr1, m_APIntAllowPoison(CINT)))
11681164
return false;
1169-
}
1165+
11701166
int ci_opr1 = (int)CINT->getSExtValue();
11711167
if (ci_opr1 == 1) { // rootn(x, 1) = x
11721168
LLVM_DEBUG(errs() << "AMDIC: " << *FPOp << " ---> " << *opr0 << "\n");

0 commit comments

Comments
 (0)