Index: lib/Transforms/Scalar/InferAddressSpaces.cpp =================================================================== --- lib/Transforms/Scalar/InferAddressSpaces.cpp +++ lib/Transforms/Scalar/InferAddressSpaces.cpp @@ -328,7 +328,8 @@ Operator *Op = cast(V); for (unsigned I = 0, E = Op->getNumOperands(); I != E; ++I) { if (ConstantExpr *CE = dyn_cast(Op->getOperand(I))) { - if (isAddressExpression(*CE) && Visited.insert(CE).second) + if (isAddressExpression(*CE) && Visited.insert(CE).second && + CE->getType()->isPointerTy()) PostorderStack.emplace_back(CE, false); } } Index: test/Transforms/InferAddressSpaces/AMDGPU/infer-address-space.ll =================================================================== --- test/Transforms/InferAddressSpaces/AMDGPU/infer-address-space.ll +++ test/Transforms/InferAddressSpaces/AMDGPU/infer-address-space.ll @@ -168,6 +168,15 @@ ret void } +; CHECK-LABEL: @select_bug( +; CHECK: %add.ptr157 = getelementptr inbounds <2 x i64>, <2 x i64>* undef, i64 select (i1 icmp ne (i32* inttoptr (i64 4873 to i32*), i32* null), i64 73, i64 93) +; CHECK: %cmp169 = icmp uge <2 x i64>* undef, %add.ptr157 +define amdgpu_kernel void @select_bug() #0 { + %add.ptr157 = getelementptr inbounds <2 x i64>, <2 x i64>* undef, i64 select (i1 icmp ne (i32* inttoptr (i64 4873 to i32*), i32* null), i64 73, i64 93) + %cmp169 = icmp uge <2 x i64>* undef, %add.ptr157 + unreachable +} + declare void @llvm.amdgcn.s.barrier() #1 declare void @use(float) #0