Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions llvm/lib/Transforms/Scalar/GVN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1659,6 +1659,9 @@ bool GVNPass::PerformLoadPRE(LoadInst *Load, AvailValInBlkVect &ValuesPerBlock,
// that we only have to insert *one* load (which means we're basically moving
// the load, not inserting a new one).

if (Load->getType()->isTokenLikeTy())
return false;

SmallPtrSet<BasicBlock *, 4> Blockers(llvm::from_range, UnavailableBlocks);

// Let's find the first basic block with more than one predecessor. Walk
Expand Down
34 changes: 34 additions & 0 deletions llvm/test/Transforms/GVN/PRE/no-pre-load-for-token-like.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
; RUN: opt -S -passes=gvn %s | FileCheck %s

; NOTE: A test to confirm GVN doesn't introduce phis for pre loads of token
; NOTE: like types. This implies the CHECKS should exactly match the IR.

define ptr @main() {
; CHECK-LABEL: define ptr @main() {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: br i1 false, label %[[ENTRY_IF_END_I_CRIT_EDGE:.*]], label %[[IF_THEN_I:.*]]
; CHECK: [[ENTRY_IF_END_I_CRIT_EDGE]]:
; CHECK-NEXT: br label %[[IF_END_I:.*]]
; CHECK: [[IF_THEN_I]]:
; CHECK-NEXT: [[TMP0:%.*]] = load target("dx.RawBuffer", half, 1, 0), ptr null, align 4
; CHECK-NEXT: [[TMP1:%.*]] = tail call ptr @llvm.dx.resource.getpointer.p0.tdx.RawBuffer_f16_1_0t(target("dx.RawBuffer", half, 1, 0) [[TMP0]], i32 0)
; CHECK-NEXT: br label %[[IF_END_I]]
; CHECK: [[IF_END_I]]:
; CHECK-NEXT: [[TMP2:%.*]] = load target("dx.RawBuffer", half, 1, 0), ptr null, align 4
; CHECK-NEXT: [[TMP3:%.*]] = tail call ptr @llvm.dx.resource.getpointer.p0.tdx.RawBuffer_f16_1_0t(target("dx.RawBuffer", half, 1, 0) [[TMP2]], i32 0)
; CHECK-NEXT: ret ptr [[TMP3]]
;
entry:
br i1 false, label %if.end.i, label %if.then.i

if.then.i: ; preds = %entry
%0 = load target("dx.RawBuffer", half, 1, 0), ptr null, align 4
%1 = tail call ptr @llvm.dx.resource.getpointer.p0.tdx.RawBuffer_f16_1_0t(target("dx.RawBuffer", half, 1, 0) %0, i32 0)
br label %if.end.i

if.end.i: ; preds = %if.then.i, %entry
%2 = load target("dx.RawBuffer", half, 1, 0), ptr null, align 4
%3 = tail call ptr @llvm.dx.resource.getpointer.p0.tdx.RawBuffer_f16_1_0t(target("dx.RawBuffer", half, 1, 0) %2, i32 0)
ret ptr %3
}