[llvm] [TargetLowering] Remove weird use of MVT::isVoid in an assert. (PR #101436)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 31 17:31:46 PDT 2024


https://github.com/topperc created https://github.com/llvm/llvm-project/pull/101436

At the time there were no vector types in MVT. The order was scalar integer types
scalar FP types
isVoid

I believe this isVoid check was to catch walking off the end of the scalar FP types. While the isInteger()==isInteger caught walking off the end of scalar integer types.

These days we have
scalar integer types
scalar FP types
fixed vector integer types
fixed vector FP types
scalable vector integer types
scalable vector FP types.
Glue
isVoid

So checking isVoid doesn't detect what it used to. I've changed it to check isFloatingPoint() == isFloatingPoint() instead.

>From 834af5a798f28afcd85d2aabf819ac177e8edf8b Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Wed, 31 Jul 2024 17:24:43 -0700
Subject: [PATCH] [TargetLowering] Remove weird use of MVT::isVoid in an
 assert.

At the time there were no vector types in MVT. The order was
scalar integer types
scalar FP types
isVoid

I believe this isVoid check was to catch walking off the end of
the scalar FP types. While the isInteger()==isInteger caught
walking off the end of scalar integer types.

These days we have
scalar integer types
scalar FP types
fixed vector integer types
fixed vector FP types
scalable vector integer types
scalable vector FP types.
Glue
isVoid

So checking isVoid doesn't detect what it used to. I've
changed it to check isFloatingPoint() == isFloatingPoint() instead.
---
 llvm/include/llvm/CodeGen/TargetLowering.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h
index 9d9886f4920a2..9ccdbab008aec 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -1640,7 +1640,8 @@ class TargetLoweringBase {
     MVT NVT = VT;
     do {
       NVT = (MVT::SimpleValueType)(NVT.SimpleTy+1);
-      assert(NVT.isInteger() == VT.isInteger() && NVT != MVT::isVoid &&
+      assert(NVT.isInteger() == VT.isInteger() &&
+             NVT.isFloatingPoint() == VT.isFloatingPoint() &&
              "Didn't find type to promote to!");
     } while (VTBits >= NVT.getScalarSizeInBits() || !isTypeLegal(NVT) ||
              getOperationAction(Op, NVT) == Promote);



More information about the llvm-commits mailing list