[Mlir-commits] [mlir] f528055 - [OMPIRBuilder] Fix store inst alignment for ordered depend directive
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Jan 13 17:47:58 PST 2022
Author: Peixin-Qiao
Date: 2022-01-14T09:47:11+08:00
New Revision: f52805539b294773aec872e9055aa460eca1a933
URL: https://github.com/llvm/llvm-project/commit/f52805539b294773aec872e9055aa460eca1a933
DIFF: https://github.com/llvm/llvm-project/commit/f52805539b294773aec872e9055aa460eca1a933.diff
LOG: [OMPIRBuilder] Fix store inst alignment for ordered depend directive
OpenMP runtime requires depend vec with i64 type and the alignment of
store instruction should be set as 8.
Reviewed By: kiranchandramohan, shraiysh
Differential Revision: https://reviews.llvm.org/D116300
Added:
Modified:
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
mlir/test/Target/LLVMIR/openmp-llvm.mlir
Removed:
################################################################################
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 68709953b48b4..f6e454b60d242 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -2494,6 +2494,10 @@ OpenMPIRBuilder::createOrderedDepend(const LocationDescription &Loc,
InsertPointTy AllocaIP, unsigned NumLoops,
ArrayRef<llvm::Value *> StoreValues,
const Twine &Name, bool IsDependSource) {
+ for (size_t I = 0; I < StoreValues.size(); I++)
+ assert(StoreValues[I]->getType()->isIntegerTy(64) &&
+ "OpenMP runtime requires depend vec with i64 type");
+
if (!updateToLocation(Loc))
return Loc.IP;
@@ -2508,7 +2512,8 @@ OpenMPIRBuilder::createOrderedDepend(const LocationDescription &Loc,
for (unsigned I = 0; I < NumLoops; ++I) {
Value *DependAddrGEPIter = Builder.CreateInBoundsGEP(
ArrI64Ty, ArgsBase, {Builder.getInt64(0), Builder.getInt64(I)});
- Builder.CreateStore(StoreValues[I], DependAddrGEPIter);
+ StoreInst *STInst = Builder.CreateStore(StoreValues[I], DependAddrGEPIter);
+ STInst->setAlignment(Align(8));
}
Value *DependBaseAddrGEP = Builder.CreateInBoundsGEP(
diff --git a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
index f200ef57be579..7e3613be8a158 100644
--- a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -2267,6 +2267,7 @@ TEST_F(OpenMPIRBuilderTest, OrderedDirectiveDependSource) {
ASSERT_NE(StoreValue, nullptr);
EXPECT_EQ(StoreValue->getValueOperand(), StoreValues[Iter]);
EXPECT_EQ(StoreValue->getPointerOperand(), DependAddrGEPIter);
+ EXPECT_EQ(StoreValue->getAlignment(), 8);
IterInst = dyn_cast<Instruction>(StoreValue);
}
@@ -2351,6 +2352,7 @@ TEST_F(OpenMPIRBuilderTest, OrderedDirectiveDependSink) {
ASSERT_NE(StoreValue, nullptr);
EXPECT_EQ(StoreValue->getValueOperand(), StoreValues[Iter]);
EXPECT_EQ(StoreValue->getPointerOperand(), DependAddrGEPIter);
+ EXPECT_EQ(StoreValue->getAlignment(), 8);
IterInst = dyn_cast<Instruction>(StoreValue);
}
diff --git a/mlir/test/Target/LLVMIR/openmp-llvm.mlir b/mlir/test/Target/LLVMIR/openmp-llvm.mlir
index 50d57bfefccea..2c8bf2098ca31 100644
--- a/mlir/test/Target/LLVMIR/openmp-llvm.mlir
+++ b/mlir/test/Target/LLVMIR/openmp-llvm.mlir
@@ -659,14 +659,14 @@ llvm.func @omp_ordered(%arg0 : i32, %arg1 : i32, %arg2 : i32, %arg3 : i64,
omp.wsloop (%arg7) : i32 = (%arg0) to (%arg1) step (%arg2) ordered(1) {
// CHECK: [[TMP:%.*]] = getelementptr inbounds [1 x i64], [1 x i64]* [[ADDR]], i64 0, i64 0
- // CHECK: store i64 [[ARG0:%.*]], i64* [[TMP]], align 4
+ // CHECK: store i64 [[ARG0:%.*]], i64* [[TMP]], align 8
// CHECK: [[TMP2:%.*]] = getelementptr inbounds [1 x i64], [1 x i64]* [[ADDR]], i64 0, i64 0
// CHECK: [[OMP_THREAD2:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @[[GLOB3:[0-9]+]])
// CHECK: call void @__kmpc_doacross_wait(%struct.ident_t* @[[GLOB3]], i32 [[OMP_THREAD2]], i64* [[TMP2]])
omp.ordered depend_type("dependsink") depend_vec(%arg3 : i64) {num_loops_val = 1 : i64}
// CHECK: [[TMP3:%.*]] = getelementptr inbounds [1 x i64], [1 x i64]* [[ADDR3]], i64 0, i64 0
- // CHECK: store i64 [[ARG0]], i64* [[TMP3]], align 4
+ // CHECK: store i64 [[ARG0]], i64* [[TMP3]], align 8
// CHECK: [[TMP4:%.*]] = getelementptr inbounds [1 x i64], [1 x i64]* [[ADDR3]], i64 0, i64 0
// CHECK: [[OMP_THREAD4:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @[[GLOB5:[0-9]+]])
// CHECK: call void @__kmpc_doacross_post(%struct.ident_t* @[[GLOB5]], i32 [[OMP_THREAD4]], i64* [[TMP4]])
@@ -677,25 +677,25 @@ llvm.func @omp_ordered(%arg0 : i32, %arg1 : i32, %arg2 : i32, %arg3 : i64,
omp.wsloop (%arg7) : i32 = (%arg0) to (%arg1) step (%arg2) ordered(2) {
// CHECK: [[TMP5:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* [[ADDR5]], i64 0, i64 0
- // CHECK: store i64 [[ARG0]], i64* [[TMP5]], align 4
+ // CHECK: store i64 [[ARG0]], i64* [[TMP5]], align 8
// CHECK: [[TMP6:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* [[ADDR5]], i64 0, i64 1
- // CHECK: store i64 [[ARG1:%.*]], i64* [[TMP6]], align 4
+ // CHECK: store i64 [[ARG1:%.*]], i64* [[TMP6]], align 8
// CHECK: [[TMP7:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* [[ADDR5]], i64 0, i64 0
// CHECK: [[OMP_THREAD6:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @[[GLOB7:[0-9]+]])
// CHECK: call void @__kmpc_doacross_wait(%struct.ident_t* @[[GLOB7]], i32 [[OMP_THREAD6]], i64* [[TMP7]])
// CHECK: [[TMP8:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* [[ADDR7]], i64 0, i64 0
- // CHECK: store i64 [[ARG2:%.*]], i64* [[TMP8]], align 4
+ // CHECK: store i64 [[ARG2:%.*]], i64* [[TMP8]], align 8
// CHECK: [[TMP9:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* [[ADDR7]], i64 0, i64 1
- // CHECK: store i64 [[ARG3:%.*]], i64* [[TMP9]], align 4
+ // CHECK: store i64 [[ARG3:%.*]], i64* [[TMP9]], align 8
// CHECK: [[TMP10:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* [[ADDR7]], i64 0, i64 0
// CHECK: [[OMP_THREAD8:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @[[GLOB7]])
// CHECK: call void @__kmpc_doacross_wait(%struct.ident_t* @[[GLOB7]], i32 [[OMP_THREAD8]], i64* [[TMP10]])
omp.ordered depend_type("dependsink") depend_vec(%arg3, %arg4, %arg5, %arg6 : i64, i64, i64, i64) {num_loops_val = 2 : i64}
// CHECK: [[TMP11:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* [[ADDR9]], i64 0, i64 0
- // CHECK: store i64 [[ARG0]], i64* [[TMP11]], align 4
+ // CHECK: store i64 [[ARG0]], i64* [[TMP11]], align 8
// CHECK: [[TMP12:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* [[ADDR9]], i64 0, i64 1
- // CHECK: store i64 [[ARG1]], i64* [[TMP12]], align 4
+ // CHECK: store i64 [[ARG1]], i64* [[TMP12]], align 8
// CHECK: [[TMP13:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* [[ADDR9]], i64 0, i64 0
// CHECK: [[OMP_THREAD10:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @[[GLOB9:[0-9]+]])
// CHECK: call void @__kmpc_doacross_post(%struct.ident_t* @[[GLOB9]], i32 [[OMP_THREAD10]], i64* [[TMP13]])
More information about the Mlir-commits
mailing list