Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 1a46c55

Browse files
committed
[AMDGPU] Fixed hang during DAG combine
SITargetLowering::reassociateScalarOps() does not touch constants so that DAGCombiner::ReassociateOps() does not revert the combine. However a global address is not a ConstantSDNode. Switched to the method used by DAGCombiner::ReassociateOps() itself to detect constants. Differential Revision: https://reviews.llvm.org/D58695 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354926 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent bf9624d commit 1a46c55

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8477,7 +8477,8 @@ SDValue SITargetLowering::reassociateScalarOps(SDNode *N,
84778477

84788478
// If either operand is constant this will conflict with
84798479
// DAGCombiner::ReassociateOps().
8480-
if (isa<ConstantSDNode>(Op0) || isa<ConstantSDNode>(Op1))
8480+
if (DAG.isConstantIntBuildVectorOrConstantInt(Op0) ||
8481+
DAG.isConstantIntBuildVectorOrConstantInt(Op1))
84818482
return SDValue();
84828483

84838484
SDLoc SL(N);

test/CodeGen/AMDGPU/reassoc-scalar.ll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,21 @@ bb:
109109
ret void
110110
}
111111

112+
@var = common hidden local_unnamed_addr addrspace(1) global [4 x i32] zeroinitializer, align 4
113+
114+
; GCN-LABEL: reassoc_i32_ga:
115+
; GCN: s_add_u32 s{{[0-9]+}}, s{{[0-9]+}}, var@rel32@lo+4
116+
; GCN: s_addc_u32 s{{[0-9]+}}, s{{[0-9]+}}, var@rel32@hi+4
117+
; GCN: s_endpgm
118+
define amdgpu_kernel void @reassoc_i32_ga(i64 %x) {
119+
bb:
120+
%tid = tail call i32 @llvm.amdgcn.workitem.id.x()
121+
%t64 = zext i32 %tid to i64
122+
%add1 = getelementptr [4 x i32], [4 x i32] addrspace(1)* @var, i64 0, i64 %t64
123+
%add2 = getelementptr i32, i32 addrspace(1)* %add1, i64 %x
124+
store volatile i32 1, i32 addrspace(1)* %add2, align 4
125+
ret void
126+
}
127+
112128
declare i32 @llvm.amdgcn.workitem.id.x()
113129
declare i32 @llvm.amdgcn.workitem.id.y()

0 commit comments

Comments
 (0)