-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[CodeGen] Use TargetLowering for TypeInfo of PointerTy #93469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-llvm-analysis @llvm/pr-subscribers-backend-x86 Author: Jan Patrick Lehr (jplehr) ChangesThis uses the TargetLowering getSimpleValueType mechanism to retrieve the ValueType info and work around a build issue we were seeing for the miniQMC application after Full diff: https://github.com/llvm/llvm-project/pull/93469.diff 1 Files Affected:
diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
index ac66144aeaaec..6616fe9274a56 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) {
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs test
I have to admit I'm a bit lost on what and where to add as a test. Guidance much appreciated! |
Depends when the crash occurs, but for example a minimal function that triggers the crash in placed in llvm/test/Transforms/SLPVectorizer/X86 would be reasonable if the crash occurred during the SLPVectorizer pass. See other files for examples. |
Thank you for your help, I hope I have moved this PR closer to being acceptable. I have reduced the failing application into a small test case that reproduces the error. I have checked the loop-vectorizer output from before the PR that broke the build to the output that it produces now and they match. My main concern (no more assertion hit) is already satisfied. However, should the generated code be added as the expected IR? Should the test be renamed? (edit: it probably should, and I'm open to suggestions) Thank you. |
@@ -0,0 +1,31 @@ | |||
; RUN: opt < %s -passes="loop-vectorize" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need the quotes. Also should use file check for something on the output. Alternatively, since this was an assertion in the cost model, can you get this down to one operation following along with test/Analysis/CostModel tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right, the test should probably go to the cost model. I don't know if I can reduce it further.
; 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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can drop this
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be able to drop noundef, local_unnamed_addr
ret ptr null | ||
} | ||
|
||
attributes #0 = { nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) "target-cpu"="znver4" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably don't need any of these, except znver4?
The test case needs diff --git a/llvm/test/Analysis/CostModel/X86/handle-iptr-with-data-layout-to-not-assert.ll b/llvm/test/Analysis/CostModel/X86/handle-iptr-with-data-layout-to-not-assert.ll
index 5278085b1182..d03dab7f7b14 100644
--- a/llvm/test/Analysis/CostModel/X86/handle-iptr-with-data-layout-to-not-assert.ll
+++ b/llvm/test/Analysis/CostModel/X86/handle-iptr-with-data-layout-to-not-assert.ll
@@ -1,9 +1,9 @@
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --filter "LV: Found an estimated cost of [0-9] for VF [0-9] For instruction:\s*store ptr %[0-9], ptr %__last" --filter "LV: Found an estimated cost of [0-9] for VF [0-9] For instruction:\s*store ptr %[0-9]" --version 5
+; REQUIRES: asserts
; RUN: opt -passes=loop-vectorize -debug-only=loop-vectorize -S < %s 2>&1 | FileCheck %s --check-prefix=CHECK_IPTR
target triple = "x86_64-unknown-linux-gnu"
-; Function Attrs: nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none)
-define noalias ptr @foo(ptr readonly %__first, ptr writeonly %__last) #0 {
+define ptr @foo(ptr %__first, ptr %__last) #0 {
; CHECK_IPTR-LABEL: 'foo'
; CHECK_IPTR: LV: Found an estimated cost of 1 for VF 1 For instruction: store ptr %0, ptr %__last, align 8
; CHECK_IPTR: LV: Found an estimated cost of 2 for VF 2 For instruction: store ptr %0, ptr %__last, align 8
@@ -14,10 +14,10 @@ entry:
%cmp.not1 = icmp eq ptr %__first, %__last
br i1 %cmp.not1, label %for.end, label %for.body.preheader
-for.body.preheader: ; preds = %entry
+for.body.preheader:
br label %for.body
-for.body: ; preds = %for.body.preheader, %for.body
+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
@@ -25,10 +25,10 @@ for.body: ; preds = %for.body.preheader,
%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
+for.end.loopexit:
br label %for.end
-for.end: ; preds = %for.end.loopexit, %entry
+for.end:
ret ptr null
} Also, please use kebab-case rather than snake_case for your FileCheck prefix, though given there's just the one in use why not just leave it at the default CHECK? |
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 llvm#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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
(I suggest putting [X86] in the commit title though) |
@jplehr, here's a small test case the reproduces the original crash. I've tested the changes in this merge request, and they seem to fix it.
|
Hi @psteinfeld thank you for that feedback. |
I'm not sure. I thought you might need a test case in C for this current PR. |
I'm gonna merge it as is, since it got accepted. If people feel that having a higher-level test is valuable it can be added. |
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
#92671.