================ @@ -259,6 +259,114 @@ class OpLowerer { lowerToBindAndAnnotateHandle(F); } + /// Replace uses of \c V with the values in the `dx.ResRet` of \c Op. Since we + /// expect to be post-scalarization, make an effort to avoid vectors. + Error replaceResRetUses(CallInst *Intrin, CallInst *Op) { + IRBuilder<> &IRB = OpBuilder.getIRB(); + + Type *OldRetTy = Intrin->getType(); + + // For scalars, we just extract the first element. + if (!isa<FixedVectorType>(OldRetTy)) { + Value *EVI = IRB.CreateExtractValue(Op, 0); + Intrin->replaceAllUsesWith(EVI); + Intrin->eraseFromParent(); + return Error::success(); + } + + auto *VecTy = cast<FixedVectorType>(OldRetTy); + unsigned N = VecTy->getNumElements(); ---------------- damyanp wrote:
`VecTy` and `N` don't seem to be used until after the line 298, IMO it'd be clearer to have these closer to where they're used. (And while I'm trying to read this, I'd really like to know if these values are mutated at all by the subsequent code) https://github.com/llvm/llvm-project/pull/104252 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits