[llvm] 3919769 - [IVDescriptorsTest] Convert to opaque pointers (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 5 01:49:40 PST 2023
Author: Nikita Popov
Date: 2023-01-05T10:49:32+01:00
New Revision: 391976919f579280fa0a85ff36e2c68913fd0850
URL: https://github.com/llvm/llvm-project/commit/391976919f579280fa0a85ff36e2c68913fd0850
DIFF: https://github.com/llvm/llvm-project/commit/391976919f579280fa0a85ff36e2c68913fd0850.diff
LOG: [IVDescriptorsTest] Convert to opaque pointers (NFC)
The LoopWithScalableTypes test is removed, because it is testing
a situation that cannot occur with opaque pointers. If we convert
this test to opaque pointers, it will not contain any scalable
types at all.
Added:
Modified:
llvm/unittests/Analysis/IVDescriptorsTest.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/Analysis/IVDescriptorsTest.cpp b/llvm/unittests/Analysis/IVDescriptorsTest.cpp
index fd9a5a801042c..83bedc9bfe55d 100644
--- a/llvm/unittests/Analysis/IVDescriptorsTest.cpp
+++ b/llvm/unittests/Analysis/IVDescriptorsTest.cpp
@@ -52,14 +52,14 @@ TEST(IVDescriptorsTest, LoopWithSingleLatch) {
std::unique_ptr<Module> M = parseIR(
Context,
- R"(define void @foo(i32* %A, i32 %ub) {
+ R"(define void @foo(ptr %A, i32 %ub) {
entry:
br label %for.body
for.body:
%i = phi i32 [ 0, %entry ], [ %inc, %for.body ]
%idxprom = sext i32 %i to i64
- %arrayidx = getelementptr inbounds i32, i32* %A, i64 %idxprom
- store i32 %i, i32* %arrayidx, align 4
+ %arrayidx = getelementptr inbounds i32, ptr %A, i64 %idxprom
+ store i32 %i, ptr %arrayidx, align 4
%inc = add nsw i32 %i, 1
%cmp = icmp slt i32 %inc, %ub
br i1 %cmp, label %for.body, label %for.exit
@@ -97,47 +97,6 @@ for.end:
});
}
-TEST(IVDescriptorsTest, LoopWithScalableTypes) {
- // Parse the module.
- LLVMContext Context;
-
- std::unique_ptr<Module> M =
- parseIR(Context,
- R"(define void @foo(<vscale x 4 x float>* %ptr) {
-entry:
- br label %for.body
-
-for.body:
- %lsr.iv1 = phi <vscale x 4 x float>* [ %0, %for.body ], [ %ptr, %entry ]
- %j.0117 = phi i64 [ %inc, %for.body ], [ 0, %entry ]
- %lsr.iv12 = bitcast <vscale x 4 x float>* %lsr.iv1 to i8*
- %inc = add nuw nsw i64 %j.0117, 1
- %uglygep = getelementptr i8, i8* %lsr.iv12, i64 4
- %0 = bitcast i8* %uglygep to <vscale x 4 x float>*
- %cmp = icmp ne i64 %inc, 1024
- br i1 %cmp, label %for.body, label %end
-
-end:
- ret void
-})");
-
- runWithLoopInfoAndSE(
- *M, "foo", [&](Function &F, LoopInfo &LI, ScalarEvolution &SE) {
- Function::iterator FI = F.begin();
- // First basic block is entry - skip it.
- BasicBlock *Header = &*(++FI);
- assert(Header->getName() == "for.body");
- Loop *L = LI.getLoopFor(Header);
- EXPECT_NE(L, nullptr);
- PHINode *Inst_iv = dyn_cast<PHINode>(&Header->front());
- assert(Inst_iv->getName() == "lsr.iv1");
- InductionDescriptor IndDesc;
- bool IsInductionPHI =
- InductionDescriptor::isInductionPHI(Inst_iv, L, &SE, IndDesc);
- EXPECT_FALSE(IsInductionPHI);
- });
-}
-
// Depending on how SCEV deals with ptrtoint cast, the step of a phi could be
// a pointer, and InductionDescriptor used to fail with an assertion.
// So just check that it doesn't assert.
@@ -152,10 +111,10 @@ TEST(IVDescriptorsTest, LoopWithPtrToInt) {
declare void @widget()
declare void @wobble(i32)
- define void @barney(i8* %arg, i8* %arg18, i32 %arg19) {
+ define void @barney(ptr %arg, ptr %arg18, i32 %arg19) {
bb:
- %tmp = ptrtoint i8* %arg to i32
- %tmp20 = ptrtoint i8* %arg18 to i32
+ %tmp = ptrtoint ptr %arg to i32
+ %tmp20 = ptrtoint ptr %arg18 to i32
%tmp21 = or i32 %tmp20, %tmp
%tmp22 = and i32 %tmp21, 3
%tmp23 = icmp eq i32 %tmp22, 0
@@ -211,15 +170,15 @@ TEST(IVDescriptorsTest, FMinRednIdentity) {
LLVMContext Context;
std::unique_ptr<Module> M = parseIR(Context,
- R"(define float @foo(float* %A, i64 %ub) {
+ R"(define float @foo(ptr %A, i64 %ub) {
entry:
br label %for.body
for.body:
%i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]
%fmin = phi float [ 1.000000e+00, %entry ], [ %fmin.next, %for.body ]
- %arrayidx = getelementptr inbounds float, float* %A, i64 %i
- %ld = load float, float* %arrayidx
+ %arrayidx = getelementptr inbounds float, ptr %A, i64 %i
+ %ld = load float, ptr %arrayidx
%fmin.cmp = fcmp nnan nsz olt float %fmin, %ld
%fmin.next = select nnan nsz i1 %fmin.cmp, float %fmin, float %ld
%i.next = add nsw i64 %i, 1
@@ -263,15 +222,15 @@ TEST(IVDescriptorsTest, FMaxRednIdentity) {
LLVMContext Context;
std::unique_ptr<Module> M = parseIR(Context,
- R"(define float @foo(float* %A, i64 %ub) {
+ R"(define float @foo(ptr %A, i64 %ub) {
entry:
br label %for.body
for.body:
%i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]
%fmax = phi float [ 1.000000e+00, %entry ], [ %fmax.next, %for.body ]
- %arrayidx = getelementptr inbounds float, float* %A, i64 %i
- %ld = load float, float* %arrayidx
+ %arrayidx = getelementptr inbounds float, ptr %A, i64 %i
+ %ld = load float, ptr %arrayidx
%fmax.cmp = fcmp nnan nsz ogt float %fmax, %ld
%fmax.next = select nnan nsz i1 %fmax.cmp, float %fmax, float %ld
%i.next = add nsw i64 %i, 1
More information about the llvm-commits
mailing list