[llvm] [llvm][TypeSize] Consider TypeSize of '0' to be fixed/scalable-agnostic. (PR #72994)

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 22 03:40:58 PST 2023


================
@@ -97,17 +97,29 @@ template <typename LeafTy, typename ValueTy> class FixedOrScalableQuantity {
 
   constexpr FixedOrScalableQuantity() = default;
   constexpr FixedOrScalableQuantity(ScalarTy Quantity, bool Scalable)
-      : Quantity(Quantity), Scalable(Scalable) {}
+      : Quantity(Quantity), Scalable(Quantity ? Scalable : false) {}
----------------
paulwalker-arm wrote:

As discussed, this might be a little dangerous right now because it'll cause functions like `isScalable` to return false when given `TypeSize::getScalable(0)`.  There's also other operators like `*` which can produce zero without going via this constructor.

It might be better to ensure all the interfaces return canonical results for fixed and scalable zero rather than changing the way zero is stored.

Whilst canonicalisation is the correct way forward if you don't specifically need it at this time then it's best removed and done in isolation.

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


More information about the llvm-commits mailing list