[llvm] [clang] [LLVM][IR] Add native vector support to ConstantInt & ConstantFP. (PR #74502)

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 5 10:07:18 PST 2023


================
@@ -136,7 +144,11 @@ class ConstantInt final : public ConstantData {
   inline const APInt &getValue() const { return Val; }
 
   /// getBitWidth - Return the bitwidth of this constant.
-  unsigned getBitWidth() const { return Val.getBitWidth(); }
+  unsigned getBitWidth() const {
+    assert(getType()->isIntegerTy() &&
+           "Returning the bitwidth of a vector constant is not support!");
----------------
nikic wrote:

Why? I think this API should work with vectors as well (with the current implementation, i.e. returning the bitwidth of the  scalar value). You can just adjust the comment to clarify.

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


More information about the cfe-commits mailing list