Skip to content

Commit 7176ce0

Browse files
committed
[SDAG] Fix CSE for ADDRSPACECAST nodes
1 parent 2201164 commit 7176ce0

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,12 @@ static void AddNodeIDCustom(FoldingSetNodeID &ID, const SDNode *N) {
954954
ID.AddInteger(M);
955955
break;
956956
}
957+
case ISD::ADDRSPACECAST: {
958+
const AddrSpaceCastSDNode *ASC = cast<AddrSpaceCastSDNode>(N);
959+
ID.AddInteger(ASC->getSrcAddressSpace());
960+
ID.AddInteger(ASC->getDestAddressSpace());
961+
break;
962+
}
957963
case ISD::TargetBlockAddress:
958964
case ISD::BlockAddress: {
959965
const BlockAddressSDNode *BA = cast<BlockAddressSDNode>(N);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
; RUN: llc < %s -mcpu=sm_80 -mattr=+ptx73 -debug-only=isel -o /dev/null 2>&1 | FileCheck %s
2+
3+
; REQUIRES: asserts
4+
5+
target triple = "nvptx64-nvidia-cuda"
6+
7+
;; Selection DAG CSE is hard to test since we run CSE/GVN on the IR before and
8+
;; after selection DAG ISel so most cases will be handled by one of these.
9+
define void @foo(ptr %p) {
10+
; CHECK-LABEL: Optimized legalized selection DAG: %bb.0 'foo:'
11+
; CHECK: addrspacecast[0 -> 5]
12+
; CHECK-NOT: addrspacecast[0 -> 5]
13+
; CHECK-LABEL: ===== Instruction selection begins
14+
;
15+
%a1 = addrspacecast ptr %p to ptr addrspace(5)
16+
call void @llvm.stackrestore(ptr %p)
17+
store ptr %p, ptr addrspace(5) %a1
18+
ret void
19+
}

0 commit comments

Comments
 (0)