[llvm] [CodeGen] Use TargetLowering for TypeInfo of PointerTy (PR #93469)
Jan Patrick Lehr via llvm-commits
llvm-commits at lists.llvm.org
Tue May 28 08:00:53 PDT 2024
https://github.com/jplehr updated https://github.com/llvm/llvm-project/pull/93469
>From b4d31585346181084c8d85784772917f83a87014 Mon Sep 17 00:00:00 2001
From: JP Lehr <JanPatrick.Lehr at amd.com>
Date: Mon, 27 May 2024 07:51:08 -0500
Subject: [PATCH] [CodeGen] Use TargetLowering for TypeInfo of PointerTy
This uses the TargetLowering getSimpleValueType mechanism to retrieve the
ValueType info and work around a build issue we were seeing for the
miniQMC application after
https://github.com/llvm/llvm-project/pull/92671.
The test is reduced from that specific application and reproduces the
issue with the loop-vectorizer pass. However, to me, it seemed that the
issue was coming from the cost model.
---
.../lib/Target/X86/X86TargetTransformInfo.cpp | 3 +-
.../LoopVectorize/cost-model-no-assert.ll | 31 +++++++++++++++++++
2 files changed, 33 insertions(+), 1 deletion(-)
create mode 100644 llvm/test/Transforms/LoopVectorize/cost-model-no-assert.ll
diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
index d935be7669f05..3b18e39d784b2 100644
--- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
+++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
@@ -6257,7 +6257,8 @@ InstructionCost X86TTIImpl::getInterleavedMemoryOpCostAVX512(
AddressSpace, CostKind);
unsigned VF = VecTy->getNumElements() / Factor;
- MVT VT = MVT::getVectorVT(MVT::getVT(VecTy->getScalarType()), VF);
+ MVT VT =
+ MVT::getVectorVT(TLI->getSimpleValueType(DL, VecTy->getScalarType()), VF);
InstructionCost MaskCost;
if (UseMaskedMemOp) {
diff --git a/llvm/test/Transforms/LoopVectorize/cost-model-no-assert.ll b/llvm/test/Transforms/LoopVectorize/cost-model-no-assert.ll
new file mode 100644
index 0000000000000..7edaf031b7a59
--- /dev/null
+++ b/llvm/test/Transforms/LoopVectorize/cost-model-no-assert.ll
@@ -0,0 +1,31 @@
+; RUN: opt < %s -passes="loop-vectorize"
+; ModuleID = 'reduced.ll'
+source_filename = "reduced.ll"
+;target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function Attrs: nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none)
+define noalias noundef ptr @foo(ptr readonly %__first, ptr writeonly %__last) local_unnamed_addr #0 {
+entry:
+ %cmp.not1 = icmp eq ptr %__first, %__last
+ br i1 %cmp.not1, label %for.end, label %for.body.preheader
+
+for.body.preheader: ; preds = %entry
+ br label %for.body
+
+for.body: ; preds = %for.body.preheader, %for.body
+ %__first.addr.02 = phi ptr [ %incdec.ptr, %for.body ], [ %__first, %for.body.preheader ]
+ %0 = load ptr, ptr %__first.addr.02, align 8
+ store ptr %0, ptr %__last, align 8
+ %incdec.ptr = getelementptr inbounds i8, ptr %__first.addr.02, i64 16
+ %cmp.not = icmp eq ptr %incdec.ptr, %__last
+ br i1 %cmp.not, label %for.end.loopexit, label %for.body
+
+for.end.loopexit: ; preds = %for.body
+ br label %for.end
+
+for.end: ; preds = %for.end.loopexit, %entry
+ ret ptr null
+}
+
+attributes #0 = { nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) "target-cpu"="znver4" }
More information about the llvm-commits
mailing list