Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 8248ba6

Browse files
Mike KleinSkia Commit-Bot
authored andcommitted
noalias for params, inbounds for GEPs
These don't get us to be able to hoist uniforms yet, but I think they're required. Tests still pass. The nullptrs in the CreateGEP calls were implied by the old special cases we were calling before. They mean, pick up the type from the pointer argument. Change-Id: Idd2b5c4b782229ebf2640f87e0ed6ebb63809042 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274583 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@google.com>
1 parent 5caf935 commit 8248ba6

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/core/SkVM.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,6 +1924,9 @@ namespace skvm {
19241924
arg_types, /*vararg?=*/false);
19251925
llvm::Function* fn
19261926
= llvm::Function::Create(fn_type, llvm::GlobalValue::ExternalLinkage, debug_name, *mod);
1927+
for (size_t i = 0; i < fStrides.size(); i++) {
1928+
fn->addParamAttr(i+1, llvm::Attribute::NoAlias);
1929+
}
19271930

19281931
llvm::BasicBlock *enter = llvm::BasicBlock::Create(ctx, "enter", fn),
19291932
*testK = llvm::BasicBlock::Create(ctx, "testK", fn),
@@ -1995,7 +1998,9 @@ namespace skvm {
19951998
case Op::uniform16: t = i16; goto uniform;
19961999
case Op::uniform32: t = i32; goto uniform;
19972000
uniform: {
1998-
llvm::Value* ptr = b->CreateBitCast(b->CreateConstGEP1_32(args[immy], immz),
2001+
llvm::Value* ptr = b->CreateBitCast(b->CreateConstInBoundsGEP1_32(nullptr,
2002+
args[immy],
2003+
immz),
19992004
t->getPointerTo());
20002005
llvm::Value* val = b->CreateZExt(b->CreateAlignedLoad(ptr, 1), i32);
20012006
vals[i] = I32->isVectorTy() ? b->CreateVectorSplat(K, val)
@@ -2008,10 +2013,12 @@ namespace skvm {
20082013
gather: {
20092014
// Our gather base pointer is immz bytes off of uniform immy.
20102015
llvm::Value* base =
2011-
b->CreateLoad(b->CreateBitCast(b->CreateConstGEP1_32(args[immy], immz),
2016+
b->CreateLoad(b->CreateBitCast(b->CreateConstInBoundsGEP1_32(nullptr,
2017+
args[immy],
2018+
immz),
20122019
t->getPointerTo()->getPointerTo()));
20132020

2014-
llvm::Value* ptr = b->CreateGEP(base, vals[x]);
2021+
llvm::Value* ptr = b->CreateInBoundsGEP(nullptr, base, vals[x]);
20152022
llvm::Value* gathered;
20162023
if (ptr->getType()->isVectorTy()) {
20172024
gathered = b->CreateMaskedGather(ptr, 1);
@@ -2189,7 +2196,8 @@ namespace skvm {
21892196

21902197
// Each arg ptr += K
21912198
for (size_t i = 0; i < fStrides.size(); i++) {
2192-
llvm::Value* arg_next = b.CreateGEP(args[i], b.getInt32(K*fStrides[i]));
2199+
llvm::Value* arg_next
2200+
= b.CreateConstInBoundsGEP1_32(nullptr, args[i], K*fStrides[i]);
21932201
args[i]->addIncoming(arg_next, loopK);
21942202
}
21952203
b.CreateBr(testK);
@@ -2229,7 +2237,8 @@ namespace skvm {
22292237

22302238
// Each arg ptr += K
22312239
for (size_t i = 0; i < fStrides.size(); i++) {
2232-
llvm::Value* arg_next = b.CreateGEP(args[i], b.getInt32(fStrides[i]));
2240+
llvm::Value* arg_next
2241+
= b.CreateConstInBoundsGEP1_32(nullptr, args[i], fStrides[i]);
22332242
args[i]->addIncoming(arg_next, loop1);
22342243
}
22352244
b.CreateBr(test1);

0 commit comments

Comments
 (0)