[PATCH] D36085: [globalisel][tablegen] Generate TypeObject table. NFC

Daniel Sanders via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 3 06:43:28 PDT 2017


dsanders added inline comments.


================
Comment at: utils/TableGen/GlobalISelEmitter.cpp:116
   bool operator<(const LLTCodeGen &Other) const {
-    if (!Ty.isValid())
-      return Other.Ty.isValid();
-    if (Ty.isScalar()) {
-      if (!Other.Ty.isValid())
-        return false;
-      if (Other.Ty.isScalar())
-        return Ty.getSizeInBits() < Other.Ty.getSizeInBits();
-      return false;
-    }
+    if (Ty.isValid() != Other.Ty.isValid())
+      return Ty.isValid() < Other.Ty.isValid();
----------------
rovka wrote:
> This is going to fall all the way to the unreachable if both types are invalid - you should check that case explicitly.
Well spotted.


================
Comment at: utils/TableGen/GlobalISelEmitter.cpp:123
+
+    if (Ty.isScalar())
+      return Ty.getSizeInBits() < Other.Ty.getSizeInBits();
----------------
rovka wrote:
> I think you can get rid of this check. If Ty.isVector, you check NumElements, and if that doesn't settle it then you can unconditionally look at the SizeInBits and it will be relevant for both scalars and vectors.
I agree.


https://reviews.llvm.org/D36085





More information about the llvm-commits mailing list