[LLVM][CodeGen][X86] Make printConstant's output for vector ConstantFP match that of ConstantVector. (#172679)

This commit is contained in:
Paul Walker 2025-12-18 11:58:05 +00:00 committed by GitHub
parent 5f84dfff53
commit cba7bb9d2f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 4 deletions

View File

@ -1565,10 +1565,16 @@ static void printConstant(const Constant *COp, unsigned BitWidth,
printConstant(CI->getValue(), CS, PrintZero);
} else if (auto *CF = dyn_cast<ConstantFP>(COp)) {
if (auto VTy = dyn_cast<FixedVectorType>(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);

View File

@ -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:

View File

@ -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: