[llvm] [AMDGPU] Simplify GetMember...::Get (NFC) (PR #137536)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 27 12:17:24 PDT 2025


================
@@ -72,17 +72,14 @@ using namespace llvm::AMDGPU;
   class GetMember##member {                                                    \
   public:                                                                      \
     static const MCExpr *Phony;                                                \
-    template <typename U, typename std::enable_if_t<IsMCExpr##member::RESULT,  \
-                                                    U> * = nullptr>            \
-    static const MCExpr *&Get(U &C) {                                          \
-      assert(IsMCExpr##member::RESULT &&                                       \
-             "Trying to retrieve member that does not exist.");                \
-      return C.member;                                                         \
-    }                                                                          \
-    template <typename U, typename std::enable_if_t<!IsMCExpr##member::RESULT, \
-                                                    U> * = nullptr>            \
-    static const MCExpr *&Get(U &C) {                                          \
-      return Phony;                                                            \
+    template <typename U> static const MCExpr *&Get(U &C) {                    \
+      if constexpr (IsMCExpr##member::RESULT) {                                \
+        assert(IsMCExpr##member::RESULT &&                                     \
+               "Trying to retrieve member that does not exist.");              \
----------------
nikic wrote:

I'd drop this assert, seeing how it now checks the same condition as the if in the directly preceding line.

https://github.com/llvm/llvm-project/pull/137536


More information about the llvm-commits mailing list