Skip to content

Commit

Permalink
Remove inline asm hack from CreateSubgroupBroadcastFirst
Browse files Browse the repository at this point in the history
  • Loading branch information
jayfoad committed Oct 9, 2023
1 parent 1180d6a commit 01271b9
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 21 deletions.
17 changes: 0 additions & 17 deletions lgc/builder/BuilderBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "lgc/util/BuilderBase.h"
#include "lgc/LgcDialect.h"
#include "lgc/state/IntrinsDefs.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/IntrinsicsAMDGPU.h"

Expand Down Expand Up @@ -279,22 +278,6 @@ Value *BuilderBase::CreateMapToSimpleType(MapToSimpleTypeFunc mapFunc, ArrayRef<
return nullptr;
}

// =====================================================================================================================
// Create an inline assembly call to cause a side effect (used to work around miscompiles with convergent).
//
// @param value : The value to ensure doesn't move in control flow.
Value *BuilderBase::CreateInlineAsmSideEffect(Value *const value) {
auto mapFunc = [](BuilderBase &builder, ArrayRef<Value *> mappedArgs, ArrayRef<Value *>) -> Value * {
Value *const value = mappedArgs[0];
Type *const type = value->getType();
FunctionType *const funcType = FunctionType::get(type, type, false);
InlineAsm *const inlineAsm = InlineAsm::get(funcType, "; %1", "=v,0", true);
return builder.CreateCall(inlineAsm, value);
};

return CreateMapToSimpleType(mapFunc, value, {});
}

// =====================================================================================================================
// Create a call to set inactive. Both active and inactive should have the same type.
//
Expand Down
2 changes: 1 addition & 1 deletion lgc/builder/SubgroupBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ Value *BuilderImpl::CreateSubgroupBroadcastFirst(Value *const value, const Twine
return builder.CreateIntrinsic(builder.getInt32Ty(), Intrinsic::amdgcn_readfirstlane, mappedArgs[0]);
};

return CreateMapToSimpleType(mapFunc, {BuilderBase::get(*this).CreateInlineAsmSideEffect(value)}, {});
return CreateMapToSimpleType(mapFunc, value, {});
}

// =====================================================================================================================
Expand Down
3 changes: 0 additions & 3 deletions lgc/include/lgc/util/BuilderBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ class BuilderBase : public BuilderCommon {
llvm::ArrayRef<llvm::Value *> passthroughArgs,
MapToSimpleMode simpleMode = MapToSimpleMode::Int32);

// Create an inline assembly call to cause a side effect (used to work around miscompiles with convergent).
llvm::Value *CreateInlineAsmSideEffect(llvm::Value *const value);

// Create a call to set inactive. Both active and inactive should have the same type.
llvm::Value *CreateSetInactive(llvm::Value *const active, llvm::Value *const inactive);

Expand Down

0 comments on commit 01271b9

Please sign in to comment.