https://github.com/bogner updated https://github.com/llvm/llvm-project/pull/104252
>From 2f317012985068f7130cdf4976d8821924d404c3 Mon Sep 17 00:00:00 2001 From: Justin Bogner <m...@justinbogner.com> Date: Mon, 9 Sep 2024 12:16:36 -0700 Subject: [PATCH 1/2] Improve comments, move code for clarity Created using spr 1.3.5-bogner --- llvm/docs/DirectX/DXILResources.rst | 2 +- llvm/lib/Target/DirectX/DXILOpLowering.cpp | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/llvm/docs/DirectX/DXILResources.rst b/llvm/docs/DirectX/DXILResources.rst index 07fba4ac644eca..8e43bfaaaf32ea 100644 --- a/llvm/docs/DirectX/DXILResources.rst +++ b/llvm/docs/DirectX/DXILResources.rst @@ -277,7 +277,7 @@ return 1 to 4 elements from the given resource, to a maximum of 16 bytes of data. DXIL's modeling of this is influenced by DirectX and DXBC's history and it generally treats these operations as returning 4 32-bit values. For 16-bit elements the values are 16-bit values, and for 64-bit values the operations -return 4 32-bit integers and combine them with further operations. +return 4 32-bit integers and emit further code to construct the double. In DXIL, these operations return `ResRet`_ and `CBufRet`_ values, are structs containing 4 elements of the same type, and in the case of `ResRet` a 5th diff --git a/llvm/lib/Target/DirectX/DXILOpLowering.cpp b/llvm/lib/Target/DirectX/DXILOpLowering.cpp index 9db18a8476b07f..409a1987709d5c 100644 --- a/llvm/lib/Target/DirectX/DXILOpLowering.cpp +++ b/llvm/lib/Target/DirectX/DXILOpLowering.cpp @@ -259,23 +259,21 @@ 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. + /// Replace uses of \c Intrin 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(); + Type *OldTy = Intrin->getType(); // For scalars, we just extract the first element. - if (!isa<FixedVectorType>(OldRetTy)) { + if (!isa<FixedVectorType>(OldTy)) { Value *EVI = IRB.CreateExtractValue(Op, 0); Intrin->replaceAllUsesWith(EVI); Intrin->eraseFromParent(); return Error::success(); } - auto *VecTy = cast<FixedVectorType>(OldRetTy); - unsigned N = VecTy->getNumElements(); std::array<Value *, 4> Extracts = {}; SmallVector<ExtractElementInst *> DynamicAccesses; @@ -296,6 +294,9 @@ class OpLowerer { } } + auto *VecTy = cast<FixedVectorType>(OldTy); + unsigned N = VecTy->getNumElements(); + // If there's a dynamic access we need to round trip through stack memory so // that we don't leave vectors around. if (!DynamicAccesses.empty()) { @@ -331,7 +332,7 @@ class OpLowerer { if (!Extracts[I]) Extracts[I] = IRB.CreateExtractValue(Op, I); - Value *Vec = UndefValue::get(OldRetTy); + Value *Vec = UndefValue::get(OldTy); for (int I = 0, E = N; I != E; ++I) Vec = IRB.CreateInsertElement(Vec, Extracts[I], I); Intrin->replaceAllUsesWith(Vec); >From 94a48e9e7cd9b4d135015114f21d5f030f0808ca Mon Sep 17 00:00:00 2001 From: Justin Bogner <m...@justinbogner.com> Date: Mon, 9 Sep 2024 12:20:52 -0700 Subject: [PATCH 2/2] Make VecTy and N const for clarity Created using spr 1.3.5-bogner --- llvm/lib/Target/DirectX/DXILOpLowering.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Target/DirectX/DXILOpLowering.cpp b/llvm/lib/Target/DirectX/DXILOpLowering.cpp index 409a1987709d5c..df2751d99576a8 100644 --- a/llvm/lib/Target/DirectX/DXILOpLowering.cpp +++ b/llvm/lib/Target/DirectX/DXILOpLowering.cpp @@ -294,8 +294,8 @@ class OpLowerer { } } - auto *VecTy = cast<FixedVectorType>(OldTy); - unsigned N = VecTy->getNumElements(); + const auto *VecTy = cast<FixedVectorType>(OldTy); + const unsigned N = VecTy->getNumElements(); // If there's a dynamic access we need to round trip through stack memory so // that we don't leave vectors around. _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits