diff options
author | Sergio Afonso <safonsof@amd.com> | 2025-02-25 10:32:54 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-25 10:32:54 +0000 |
commit | 56975b4ecd188a77b4f9420ff8aa5d5a72e4e076 (patch) | |
tree | 7cf89a2b3c42cafaec2be98b6ed74bba97c048ac /llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp | |
parent | 48397fe41ee67557e00f13f35d60c3c9b8485e89 (diff) | |
download | llvm-56975b4ecd188a77b4f9420ff8aa5d5a72e4e076.zip llvm-56975b4ecd188a77b4f9420ff8aa5d5a72e4e076.tar.gz llvm-56975b4ecd188a77b4f9420ff8aa5d5a72e4e076.tar.bz2 |
[OpenMPIRBuilder] Split calculation of canonical loop trip count, NFC (#127820)
This patch splits off the calculation of canonical loop trip counts from
the creation of canonical loops. This makes it possible to reuse this
logic to, for instance, populate the `__tgt_target_kernel` runtime call
for SPMD kernels.
This feature is used to simplify one of the existing OpenMPIRBuilder
tests.
Diffstat (limited to 'llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp')
-rw-r--r-- | llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp index a1ea784..27c0e0b 100644 --- a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp +++ b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp @@ -1441,8 +1441,7 @@ TEST_F(OpenMPIRBuilderTest, CanonicalLoopSimple) { EXPECT_EQ(&Loop->getAfter()->front(), RetInst); } -TEST_F(OpenMPIRBuilderTest, CanonicalLoopBounds) { - using InsertPointTy = OpenMPIRBuilder::InsertPointTy; +TEST_F(OpenMPIRBuilderTest, CanonicalLoopTripCount) { OpenMPIRBuilder OMPBuilder(*M); OMPBuilder.initialize(); IRBuilder<> Builder(BB); @@ -1458,17 +1457,8 @@ TEST_F(OpenMPIRBuilderTest, CanonicalLoopBounds) { Value *StartVal = ConstantInt::get(LCTy, Start); Value *StopVal = ConstantInt::get(LCTy, Stop); Value *StepVal = ConstantInt::get(LCTy, Step); - auto LoopBodyGenCB = [&](InsertPointTy CodeGenIP, llvm::Value *LC) { - return Error::success(); - }; - ASSERT_EXPECTED_INIT_RETURN( - CanonicalLoopInfo *, Loop, - OMPBuilder.createCanonicalLoop(Loc, LoopBodyGenCB, StartVal, StopVal, - StepVal, IsSigned, InclusiveStop), - -1); - Loop->assertOK(); - Builder.restoreIP(Loop->getAfterIP()); - Value *TripCount = Loop->getTripCount(); + Value *TripCount = OMPBuilder.calculateCanonicalLoopTripCount( + Loc, StartVal, StopVal, StepVal, IsSigned, InclusiveStop); return cast<ConstantInt>(TripCount)->getValue().getZExtValue(); }; |