[llvm] [NFC][LLVM][CodeGen][X86] Add ConstantInt/FP based vector support to MachineInstr fixup and printing code. (PR #137331)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Fri May 2 07:07:43 PDT 2025


================
@@ -88,11 +88,19 @@ static std::optional<APInt> extractConstantBits(const Constant *C) {
   if (isa<UndefValue>(C))
     return APInt::getZero(NumBits);
 
-  if (auto *CInt = dyn_cast<ConstantInt>(C))
+  if (auto *CInt = dyn_cast<ConstantInt>(C)) {
+    if (isa<VectorType>(CInt->getType()))
+      return APInt::getSplat(NumBits, CInt->getValue());
----------------
RKSimon wrote:

This was the first time I've seen ConstantInt/FP being used as splats like this - hiding the handling inside existing use cases feels like it going to cause people to miss this in future as well. All I had in mind was a ConstantInt/FP::getRawBits() wrapper.

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


More information about the llvm-commits mailing list