diff --git a/llvm/lib/Target/X86/X86MCInstLower.cpp b/llvm/lib/Target/X86/X86MCInstLower.cpp index 713d504474f5..2287a921a19c 100644 --- a/llvm/lib/Target/X86/X86MCInstLower.cpp +++ b/llvm/lib/Target/X86/X86MCInstLower.cpp @@ -1565,10 +1565,16 @@ static void printConstant(const Constant *COp, unsigned BitWidth, printConstant(CI->getValue(), CS, PrintZero); } else if (auto *CF = dyn_cast(COp)) { if (auto VTy = dyn_cast(CF->getType())) { - for (unsigned I = 0, E = VTy->getNumElements(); I != E; ++I) { - if (I != 0) - CS << ','; - printConstant(CF->getValueAPF(), CS, PrintZero); + unsigned EltBits = VTy->getScalarSizeInBits(); + unsigned E = std::min(BitWidth / EltBits, VTy->getNumElements()); + if ((BitWidth % EltBits) == 0) { + for (unsigned I = 0; I != E; ++I) { + if (I != 0) + CS << ","; + printConstant(CF->getValueAPF(), CS, PrintZero); + } + } else { + CS << "?"; } } else printConstant(CF->getValueAPF(), CS, PrintZero); diff --git a/llvm/test/CodeGen/X86/combine-concatvectors.ll b/llvm/test/CodeGen/X86/combine-concatvectors.ll index 7237b02ca6b6..bfc1a3c82de6 100644 --- a/llvm/test/CodeGen/X86/combine-concatvectors.ll +++ b/llvm/test/CodeGen/X86/combine-concatvectors.ll @@ -1,6 +1,8 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s --check-prefixes=CHECK,AVX1 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefixes=CHECK,AVX2 +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx -use-constant-fp-for-fixed-length-splat | FileCheck %s --check-prefixes=CHECK,AVX1 +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 -use-constant-fp-for-fixed-length-splat | FileCheck %s --check-prefixes=CHECK,AVX2 define void @PR32957(ptr %in, ptr %out) { ; CHECK-LABEL: PR32957: diff --git a/llvm/test/CodeGen/X86/pr131389.ll b/llvm/test/CodeGen/X86/pr131389.ll index e53536b084b2..e1a538925b8c 100644 --- a/llvm/test/CodeGen/X86/pr131389.ll +++ b/llvm/test/CodeGen/X86/pr131389.ll @@ -1,5 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 ; RUN: llc < %s -mtriple=x86_64-- | FileCheck %s +; RUN: llc < %s -mtriple=x86_64-- -use-constant-fp-for-fixed-length-splat | FileCheck %s define void @PR131389(ptr %p) { ; CHECK-LABEL: PR131389: