[PATCH] D85912: [VectorCombine] Fix for non-zero addrspace when creating vector load from scalar load
Bjorn Pettersson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 13 09:26:56 PDT 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG11446b02c7ec: [VectorCombine] Fix for non-zero addrspace when creating vector load from… (authored by bjope).
Changed prior to commit:
https://reviews.llvm.org/D85912?vs=285387&id=285403#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85912/new/
https://reviews.llvm.org/D85912
Files:
llvm/lib/Transforms/Vectorize/VectorCombine.cpp
llvm/test/Transforms/VectorCombine/X86/load.ll
Index: llvm/test/Transforms/VectorCombine/X86/load.ll
===================================================================
--- llvm/test/Transforms/VectorCombine/X86/load.ll
+++ llvm/test/Transforms/VectorCombine/X86/load.ll
@@ -234,6 +234,19 @@
ret <4 x float> %r
}
+; Should work with addrspace as well.
+
+define <4 x float> @gep00_load_f32_insert_v4f32_addrspace(<4 x float> addrspace(44)* align 16 dereferenceable(16) %p) {
+; CHECK-LABEL: @gep00_load_f32_insert_v4f32_addrspace(
+; CHECK-NEXT: [[R:%.*]] = load <4 x float>, <4 x float> addrspace(44)* [[P:%.*]], align 16
+; CHECK-NEXT: ret <4 x float> [[R]]
+;
+ %gep = getelementptr inbounds <4 x float>, <4 x float> addrspace(44)* %p, i64 0, i64 0
+ %s = load float, float addrspace(44)* %gep, align 16
+ %r = insertelement <4 x float> undef, float %s, i64 0
+ ret <4 x float> %r
+}
+
; If there are enough dereferenceable bytes, we can offset the vector load.
define <8 x i16> @gep01_load_i16_insert_v8i16(<8 x i16>* align 16 dereferenceable(18) %p) {
Index: llvm/lib/Transforms/Vectorize/VectorCombine.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -121,15 +121,15 @@
if (!isSafeToLoadUnconditionally(PtrOp, VectorTy, Alignment, DL, Load, &DT))
return false;
+ unsigned AS = Load->getPointerAddressSpace();
+
// Original pattern: insertelt undef, load [free casts of] ScalarPtr, 0
- int OldCost = TTI.getMemoryOpCost(Instruction::Load, ScalarTy, Alignment,
- Load->getPointerAddressSpace());
+ int OldCost = TTI.getMemoryOpCost(Instruction::Load, ScalarTy, Alignment, AS);
APInt DemandedElts = APInt::getOneBitSet(VecNumElts, 0);
OldCost += TTI.getScalarizationOverhead(VectorTy, DemandedElts, true, false);
// New pattern: load VecPtr
- int NewCost = TTI.getMemoryOpCost(Instruction::Load, VectorTy, Alignment,
- Load->getPointerAddressSpace());
+ int NewCost = TTI.getMemoryOpCost(Instruction::Load, VectorTy, Alignment, AS);
// We can aggressively convert to the vector form because the backend can
// invert this transform if it does not result in a performance win.
@@ -139,7 +139,7 @@
// It is safe and potentially profitable to load a vector directly:
// inselt undef, load Scalar, 0 --> load VecPtr
IRBuilder<> Builder(Load);
- Value *CastedPtr = Builder.CreateBitCast(PtrOp, VectorTy->getPointerTo());
+ Value *CastedPtr = Builder.CreateBitCast(PtrOp, VectorTy->getPointerTo(AS));
LoadInst *VecLd = Builder.CreateAlignedLoad(VectorTy, CastedPtr, Alignment);
replaceValue(I, *VecLd);
++NumVecLoad;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85912.285403.patch
Type: text/x-patch
Size: 2744 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200813/0a780a98/attachment-0001.bin>
More information about the llvm-commits
mailing list