<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/64079>64079</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            NVPTX cannot select AtomicLoad with OpenMP and Eigen
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          markdewing
      </td>
    </tr>
</table>

<pre>
    As mentioned at the end of #64017, if Eigen is modified to remove the dynamic stack allocation, another 'cannot select' error results
```
LLVM ERROR: Cannot select: t47: i16,ch = AtomicLoad<(dereferenceable load acquire (s8) from `ptr addrspacecast (ptr addrspace(1) @_ZGVZN5Eigen8internal20manage_caching_sizesENS_6ActionEPlS2_S2_E12m_cacheSizes to ptr)`, align 8)> t26, t28
  t28: i64 = addrspacecast[1 -> 0] t51
 t51: i64 = NVPTXISD::Wrapper TargetGlobalAddress:i64<ptr addrspace(1) @_ZGVZN5Eigen8internal20manage_caching_sizesENS_6ActionEPlS2_S2_E12m_cacheSizes> 0
      t50: i64 = TargetGlobalAddress<ptr addrspace(1) @_ZGVZN5Eigen8internal20manage_caching_sizesENS_6ActionEPlS2_S2_E12m_cacheSizes> 0
In function: _ZN5Eigen8internal20manage_caching_sizesENS_6ActionEPlS2_S2_
```

Use the test case from #64017, and modify Eigen to undefine `EIGEN_ALLOCA` after it is defined in Core/util/Memory.h
The diff is
```
diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h
index f4217e261..6a8d2e738 100644
--- a/Eigen/src/Core/util/Memory.h
+++ b/Eigen/src/Core/util/Memory.h
@@ -680,6 +680,8 @@ template<typename T> EIGEN_DEVICE_FUNC T* smart_move(T* start, T* end, T* target
   #undef EIGEN_ALLOCA
 #endif
 
+#undef EIGEN_ALLOCA
+
 // This helper class construct the allocated memory, and takes care of destructing and freeing the handled data
 // at destruction time. In practice this helper class is mainly useful to avoid memory leak in case of exceptions.
 template<typename T> class aligned_stack_memory_handler : noncopyable
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8Vs1u2zgQfhr6MrAhUT-WDz44jl0ESNOiSbOLXoQxObK4oUgtSbX1Pv2CktPGRQp0sUANwaLEmeE3P9-M0Ht1NERrVlyx4nqGQ2itW3foniR9UeY4O1h5Wm88dGSCsoYkYIDQEpCRYBtgPCvzJF0yvgXVwE4dyYDy0FmpGkUSggVHnf1Mo5Y8GeyUAB9QPAFqbQVGu1EdjQ0tOWB8KdAYG8CTJhEYXwI5Zx048oMOniXXLNmwMjlf4-Pt7eNb2H348O4DyzawvTCQbSDky3hTacn4VrTAsmvYBNspcWtRsmzLeCXJUUOOjCA8aAJtUQKKvwflCBivfMX4ChpnO2Bl0gcHKKXzPQoS6EMUuXjJeJVGDZYn9ac3j5_uijE8lTKBnEHNkw4NHqkWKFpljrVX_5Df3d3X5UbEqOze63te3_N6l_JulKL7KBKD2gfH-Cq6H0On1dFAhMeyHQQenYTAqyk0MC6j92U-On4BmxVXKcyjXsKKawhFetaKqxdKd4_vH_68ub9m2YZlmz8c9j05eEB3pPBG2wPqjZSOvGfZRpU5y7a_JxgT8rOj8ReK5CXuVxH-fmw3BprBjNIRXf0_Dnm1_qf_j37iWSAfQKCnc7m-YCkaObHzdGZrsDAYSY0yFOt6d_Nmd1dvbm_fbeMZgE0gBypEVk9SEpSBrXXE-H4ISjO-f0uddadFO6F4iExXTQPqda6Oe_P5UQVAxvcjDMb33gnG968bhsMvCk4nKCPpKzQ5T5fEy3SxKLGSnJZZBWmSlHk-ic3n819GcPaEX03XfwTE8oTlCczLKhK2BMavpmUF561AXa8xEMu24dSTwY7gIRbQlJDr3ePNdlfvP95t4YHxDfgOXahjZ2W8mt4EdCGmeHwiI7-tw8iBbyRhPBszDhe5nnYZz8hI1Tw_fvf6pzpx91l5z_geHlrloSUdG4TQ6D0Ia3xwg5hmx7nvk4RuDNJz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