[Mlir-commits] [flang] [mlir] [LLVM-Flang][OpenMP] Fix to resolve the crash with SIMD aligned clause. (PR #150612)

Kaviya Rajendiran llvmlistbot at llvm.org
Mon Jul 28 09:56:32 PDT 2025


https://github.com/kaviya2510 updated https://github.com/llvm/llvm-project/pull/150612

>From e9b5c15cdebdd960cdda16172fdab640c0ae5ba7 Mon Sep 17 00:00:00 2001
From: Kaviya Rajendiran <kaviyara2000 at gmail.com>
Date: Fri, 25 Jul 2025 17:52:51 +0530
Subject: [PATCH 1/3] [LLVM-Flang][OpenMP] Fix to resolve the crash with SIMD
 aligned clause.

---
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp     |  6 ++----
 flang/lib/Semantics/check-omp-structure.cpp    |  7 ++++++-
 flang/test/Lower/OpenMP/simd.f90               | 17 +++++++++++++++++
 flang/test/Semantics/OpenMP/simd-aligned.f90   |  7 +++++++
 .../OpenMP/OpenMPToLLVMIRTranslation.cpp       |  5 +++++
 .../Target/LLVMIR/openmp-simd-aligned.mlir     | 18 ++++++++++++++++++
 6 files changed, 55 insertions(+), 5 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index 594f95ecdda63..8f541f9bb4e03 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -647,10 +647,8 @@ addAlignedClause(lower::AbstractConverter &converter,
 
   // The default alignment for some targets is equal to 0.
   // Do not generate alignment assumption if alignment is less than or equal to
-  // 0.
-  if (alignment > 0) {
-    // alignment value must be power of 2
-    assert((alignment & (alignment - 1)) == 0 && "alignment is not power of 2");
+  // 0 or not a power of two
+  if (alignment > 0 && ((alignment & (alignment - 1)) == 0)) {
     auto &objects = std::get<omp::ObjectList>(clause.t);
     if (!objects.empty())
       genObjectList(objects, converter, alignedVars);
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index d214d222e7c90..c19abea5becf8 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -3244,9 +3244,14 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Aligned &x) {
           x.v, llvm::omp::OMPC_aligned, GetContext().clauseSource, context_)) {
     auto &modifiers{OmpGetModifiers(x.v)};
     if (auto *align{OmpGetUniqueModifier<parser::OmpAlignment>(modifiers)}) {
-      if (const auto &v{GetIntValue(align->v)}; !v || *v <= 0) {
+      const auto &v{GetIntValue(align->v)};
+      if (!v || *v <= 0) {
         context_.Say(OmpGetModifierSource(modifiers, align),
             "The alignment value should be a constant positive integer"_err_en_US);
+      } else if (((*v) & (*v - 1)) != 0) {
+        context_.Warn(common::UsageWarning::OpenMPUsage,
+            OmpGetModifierSource(modifiers, align),
+            "Alignment is not a power of 2, Aligned clause will be ignored"_warn_en_US);
       }
     }
   }
diff --git a/flang/test/Lower/OpenMP/simd.f90 b/flang/test/Lower/OpenMP/simd.f90
index d815474b84b31..7655c786573e3 100644
--- a/flang/test/Lower/OpenMP/simd.f90
+++ b/flang/test/Lower/OpenMP/simd.f90
@@ -226,6 +226,23 @@ subroutine simdloop_aligned_allocatable()
   end do
 end subroutine
 
+subroutine aligned_non_power_of_two()
+  integer :: i
+  integer, allocatable :: A(:)
+  allocate(A(10))
+!CHECK: %[[A_PTR:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>> {bindc_name = "a",
+!CHECK-SAME: uniq_name = "_QFaligned_non_power_of_twoEa"}
+!CHECK: %[[A_DECL:.*]]:2 = hlfir.declare %[[A_PTR]] {fortran_attrs = #fir.var_attrs<allocatable>,
+!CHECK-SAME: uniq_name = "_QFaligned_non_power_of_twoEa"} :
+!CHECK-SAME: (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) ->
+!CHECK-SAME: (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>)
+!CHECK: omp.simd private
+  !$OMP SIMD ALIGNED(A:257)
+  do i = 1, 10
+    A(i) = i
+  end do
+end subroutine
+
 !CHECK-LABEL: func @_QPsimd_with_nontemporal_clause
 subroutine simd_with_nontemporal_clause(n)
   !CHECK: %[[A_DECL:.*]]:2 = hlfir.declare %{{.*}} {uniq_name = "_QFsimd_with_nontemporal_clauseEa"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
diff --git a/flang/test/Semantics/OpenMP/simd-aligned.f90 b/flang/test/Semantics/OpenMP/simd-aligned.f90
index 0a9f95833e22e..4c410a7c4631b 100644
--- a/flang/test/Semantics/OpenMP/simd-aligned.f90
+++ b/flang/test/Semantics/OpenMP/simd-aligned.f90
@@ -60,9 +60,16 @@ program omp_simd
   !$omp end simd
 
   !ERROR: 'd' in ALIGNED clause must be of type C_PTR, POINTER or ALLOCATABLE
+  !WARNING: Alignment is not a power of 2, Aligned clause will be ignored [-Wopen-mp-usage]
   !$omp simd aligned(d:100)
   do i = 1, 100
     d(i) = i
   end do
 
+  !WARNING: Alignment is not a power of 2, Aligned clause will be ignored [-Wopen-mp-usage]
+  !$omp simd aligned(b:65)
+  do i = 1, 100
+    b(i) = i
+  end do
+
 end program omp_simd
diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index 9f18199c75b4b..48010c7ec1a14 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -2893,6 +2893,11 @@ convertOmpSimd(Operation &opInst, llvm::IRBuilderBase &builder,
     alignment = builder.getInt64(intAttr.getInt());
     assert(ty->isPointerTy() && "Invalid type for aligned variable");
     assert(alignment && "Invalid alignment value");
+    // Check if the alignment value is not a power of 2. If so, skip emitting
+    // alignment.
+    if (!intAttr.getValue().isPowerOf2())
+      continue;
+
     auto curInsert = builder.saveIP();
     builder.SetInsertPoint(sourceBlock);
     llvmVal = builder.CreateLoad(ty, llvmVal);
diff --git a/mlir/test/Target/LLVMIR/openmp-simd-aligned.mlir b/mlir/test/Target/LLVMIR/openmp-simd-aligned.mlir
index 234604e4b664a..fd19ca15f5df0 100644
--- a/mlir/test/Target/LLVMIR/openmp-simd-aligned.mlir
+++ b/mlir/test/Target/LLVMIR/openmp-simd-aligned.mlir
@@ -58,3 +58,21 @@ llvm.func @_QPsimd_aligned_allocatable() {
   }
   llvm.return
 }
+
+//CHECK-LABEL: define void @_QPsimd_aligned_non_power_of_two() {
+//CHECK:   %[[A_ADDR:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, i64 1, align 8
+//CHECK-NOT:   call void @llvm.assume(i1 true) [ "align"(ptr %{{.*}}, i64 256) ]
+llvm.func @_QPsimd_aligned_non_power_of_two() {
+  %0 = llvm.mlir.constant(1 : i64) : i64
+  %1 = llvm.alloca %0 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)> {bindc_name = "a"} : (i64) -> !llvm.ptr
+  %2 = llvm.mlir.constant(1 : i32) : i32
+  %3 = llvm.mlir.constant(10 : i32) : i32
+  %4 = llvm.mlir.constant(1 : i32) : i32
+  omp.simd aligned(%1 : !llvm.ptr -> 257 : i64) {
+    omp.loop_nest (%arg0) : i32 = (%2) to (%3) inclusive step (%4) {
+      omp.yield
+    }
+  }
+  llvm.return
+}
+

>From f02b748ba14fd7e95b89f56befc297c2cebb30de Mon Sep 17 00:00:00 2001
From: Kaviya Rajendiran <kaviyara2000 at gmail.com>
Date: Mon, 28 Jul 2025 19:29:46 +0530
Subject: [PATCH 2/3] [LLVM-Flang][OpenMP] Emit the warning for aligned clause
 in OpenMPDialect::verifyAlignedClause()

---
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp       |  4 ++--
 flang/lib/Semantics/check-omp-structure.cpp      |  7 +------
 flang/test/Lower/OpenMP/simd.f90                 |  3 ++-
 flang/test/Semantics/OpenMP/simd-aligned.f90     |  7 -------
 mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp     | 10 +++++++++-
 mlir/test/Dialect/OpenMP/invalid.mlir            | 14 ++++++++++++++
 mlir/test/Target/LLVMIR/openmp-simd-aligned.mlir |  2 +-
 7 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index 8f541f9bb4e03..cc5b8dbe4acc0 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -647,8 +647,8 @@ addAlignedClause(lower::AbstractConverter &converter,
 
   // The default alignment for some targets is equal to 0.
   // Do not generate alignment assumption if alignment is less than or equal to
-  // 0 or not a power of two
-  if (alignment > 0 && ((alignment & (alignment - 1)) == 0)) {
+  // 0.
+  if (alignment > 0) {
     auto &objects = std::get<omp::ObjectList>(clause.t);
     if (!objects.empty())
       genObjectList(objects, converter, alignedVars);
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index c19abea5becf8..d214d222e7c90 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -3244,14 +3244,9 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Aligned &x) {
           x.v, llvm::omp::OMPC_aligned, GetContext().clauseSource, context_)) {
     auto &modifiers{OmpGetModifiers(x.v)};
     if (auto *align{OmpGetUniqueModifier<parser::OmpAlignment>(modifiers)}) {
-      const auto &v{GetIntValue(align->v)};
-      if (!v || *v <= 0) {
+      if (const auto &v{GetIntValue(align->v)}; !v || *v <= 0) {
         context_.Say(OmpGetModifierSource(modifiers, align),
             "The alignment value should be a constant positive integer"_err_en_US);
-      } else if (((*v) & (*v - 1)) != 0) {
-        context_.Warn(common::UsageWarning::OpenMPUsage,
-            OmpGetModifierSource(modifiers, align),
-            "Alignment is not a power of 2, Aligned clause will be ignored"_warn_en_US);
       }
     }
   }
diff --git a/flang/test/Lower/OpenMP/simd.f90 b/flang/test/Lower/OpenMP/simd.f90
index 7655c786573e3..4e1eb4b320bcf 100644
--- a/flang/test/Lower/OpenMP/simd.f90
+++ b/flang/test/Lower/OpenMP/simd.f90
@@ -230,13 +230,14 @@ subroutine aligned_non_power_of_two()
   integer :: i
   integer, allocatable :: A(:)
   allocate(A(10))
+!CHECK-WARN: {{.*}} warning: loc({{.*}}simd.f90{{.*}}): Alignment is not a power of 2, alignment will be ignored.
 !CHECK: %[[A_PTR:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>> {bindc_name = "a",
 !CHECK-SAME: uniq_name = "_QFaligned_non_power_of_twoEa"}
 !CHECK: %[[A_DECL:.*]]:2 = hlfir.declare %[[A_PTR]] {fortran_attrs = #fir.var_attrs<allocatable>,
 !CHECK-SAME: uniq_name = "_QFaligned_non_power_of_twoEa"} :
 !CHECK-SAME: (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) ->
 !CHECK-SAME: (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>)
-!CHECK: omp.simd private
+!CHECK: omp.simd aligned(%[[A_DECL]]#0 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> -> 257 : i64)
   !$OMP SIMD ALIGNED(A:257)
   do i = 1, 10
     A(i) = i
diff --git a/flang/test/Semantics/OpenMP/simd-aligned.f90 b/flang/test/Semantics/OpenMP/simd-aligned.f90
index 4c410a7c4631b..0a9f95833e22e 100644
--- a/flang/test/Semantics/OpenMP/simd-aligned.f90
+++ b/flang/test/Semantics/OpenMP/simd-aligned.f90
@@ -60,16 +60,9 @@ program omp_simd
   !$omp end simd
 
   !ERROR: 'd' in ALIGNED clause must be of type C_PTR, POINTER or ALLOCATABLE
-  !WARNING: Alignment is not a power of 2, Aligned clause will be ignored [-Wopen-mp-usage]
   !$omp simd aligned(d:100)
   do i = 1, 100
     d(i) = i
   end do
 
-  !WARNING: Alignment is not a power of 2, Aligned clause will be ignored [-Wopen-mp-usage]
-  !$omp simd aligned(b:65)
-  do i = 1, 100
-    b(i) = i
-  end do
-
 end program omp_simd
diff --git a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
index c1c1767ef90b0..83fd3fea55c74 100644
--- a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -264,11 +264,19 @@ static LogicalResult verifyAlignedClause(Operation *op,
   if (!alignments)
     return success();
 
+  static bool emitWarn = false;
   // Check if all alignment values are positive - OpenMP 4.5 -> 2.8.1 section
   for (unsigned i = 0; i < (*alignments).size(); ++i) {
     if (auto intAttr = llvm::dyn_cast<IntegerAttr>((*alignments)[i])) {
-      if (intAttr.getValue().sle(0))
+      auto alignment = intAttr.getValue();
+      if (alignment.sle(0))
         return op->emitOpError() << "alignment should be greater than 0";
+      else if (!alignment.isPowerOf2() && !emitWarn) {
+        emitWarn = true;
+        emitWarning(
+            op->getLoc(),
+            "Alignment is not a power of 2, aligned clause will be ignored");
+      }
     } else {
       return op->emitOpError() << "expected integer alignment";
     }
diff --git a/mlir/test/Dialect/OpenMP/invalid.mlir b/mlir/test/Dialect/OpenMP/invalid.mlir
index 5088f2dfa7d7a..cc9853ba4b72a 100644
--- a/mlir/test/Dialect/OpenMP/invalid.mlir
+++ b/mlir/test/Dialect/OpenMP/invalid.mlir
@@ -370,6 +370,20 @@ func.func @omp_simd_unexpected_alignment(%arg0 : index, %arg1 : index,
 
 // -----
 
+func.func @omp_simd_non_power_of_two_alignment(%arg0 : index, %arg1 : index,
+                                     %arg2 : index, %arg3 : memref<i32>,
+                                     %arg4 : memref<i32>) -> () {
+  //  expected-warning @below {{Alignment is not a power of 2, aligned clause will be ignored}}
+  "omp.simd"(%arg3, %arg4) ({
+    omp.loop_nest (%iv) : index = (%arg0) to (%arg1) step (%arg2) {
+      omp.yield
+    }
+  }) {alignments = [64, 127], operandSegmentSizes = array<i32: 2, 0, 0, 0, 0, 0, 0>} : (memref<i32>, memref<i32>) -> ()
+  return
+}
+
+// -----
+
 func.func @omp_simd_aligned_float(%arg0 : index, %arg1 : index,
                                   %arg2 : index, %arg3 : memref<i32>,
                                   %arg4 : memref<i32>) -> () {
diff --git a/mlir/test/Target/LLVMIR/openmp-simd-aligned.mlir b/mlir/test/Target/LLVMIR/openmp-simd-aligned.mlir
index fd19ca15f5df0..560c933e4dc2a 100644
--- a/mlir/test/Target/LLVMIR/openmp-simd-aligned.mlir
+++ b/mlir/test/Target/LLVMIR/openmp-simd-aligned.mlir
@@ -61,7 +61,7 @@ llvm.func @_QPsimd_aligned_allocatable() {
 
 //CHECK-LABEL: define void @_QPsimd_aligned_non_power_of_two() {
 //CHECK:   %[[A_ADDR:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, i64 1, align 8
-//CHECK-NOT:   call void @llvm.assume(i1 true) [ "align"(ptr %{{.*}}, i64 256) ]
+//CHECK-NOT:   call void @llvm.assume(i1 true) [ "align"(ptr %{{.*}}, i64 257) ]
 llvm.func @_QPsimd_aligned_non_power_of_two() {
   %0 = llvm.mlir.constant(1 : i64) : i64
   %1 = llvm.alloca %0 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)> {bindc_name = "a"} : (i64) -> !llvm.ptr

>From 7ada03debae75b5a45afbd04659dfa09ba11e583 Mon Sep 17 00:00:00 2001
From: Kaviya Rajendiran <kaviyara2000 at gmail.com>
Date: Mon, 28 Jul 2025 22:25:56 +0530
Subject: [PATCH 3/3] [LLVM-Flang][OpenMP] Removed all the previous checks and
 emit warning during LLVM IR translation of aligned clause

---
 flang/test/Lower/OpenMP/simd.f90                   |  1 -
 mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp       | 10 +---------
 .../Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp   |  6 +++++-
 mlir/test/Dialect/OpenMP/invalid.mlir              | 14 --------------
 mlir/test/Target/LLVMIR/openmp-simd-aligned.mlir   | 14 +++++++++-----
 5 files changed, 15 insertions(+), 30 deletions(-)

diff --git a/flang/test/Lower/OpenMP/simd.f90 b/flang/test/Lower/OpenMP/simd.f90
index 4e1eb4b320bcf..f917f13d39a95 100644
--- a/flang/test/Lower/OpenMP/simd.f90
+++ b/flang/test/Lower/OpenMP/simd.f90
@@ -230,7 +230,6 @@ subroutine aligned_non_power_of_two()
   integer :: i
   integer, allocatable :: A(:)
   allocate(A(10))
-!CHECK-WARN: {{.*}} warning: loc({{.*}}simd.f90{{.*}}): Alignment is not a power of 2, alignment will be ignored.
 !CHECK: %[[A_PTR:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>> {bindc_name = "a",
 !CHECK-SAME: uniq_name = "_QFaligned_non_power_of_twoEa"}
 !CHECK: %[[A_DECL:.*]]:2 = hlfir.declare %[[A_PTR]] {fortran_attrs = #fir.var_attrs<allocatable>,
diff --git a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
index 83fd3fea55c74..c1c1767ef90b0 100644
--- a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -264,19 +264,11 @@ static LogicalResult verifyAlignedClause(Operation *op,
   if (!alignments)
     return success();
 
-  static bool emitWarn = false;
   // Check if all alignment values are positive - OpenMP 4.5 -> 2.8.1 section
   for (unsigned i = 0; i < (*alignments).size(); ++i) {
     if (auto intAttr = llvm::dyn_cast<IntegerAttr>((*alignments)[i])) {
-      auto alignment = intAttr.getValue();
-      if (alignment.sle(0))
+      if (intAttr.getValue().sle(0))
         return op->emitOpError() << "alignment should be greater than 0";
-      else if (!alignment.isPowerOf2() && !emitWarn) {
-        emitWarn = true;
-        emitWarning(
-            op->getLoc(),
-            "Alignment is not a power of 2, aligned clause will be ignored");
-      }
     } else {
       return op->emitOpError() << "expected integer alignment";
     }
diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index 48010c7ec1a14..2b4e874ab04e1 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -2895,8 +2895,12 @@ convertOmpSimd(Operation &opInst, llvm::IRBuilderBase &builder,
     assert(alignment && "Invalid alignment value");
     // Check if the alignment value is not a power of 2. If so, skip emitting
     // alignment.
-    if (!intAttr.getValue().isPowerOf2())
+    if (!intAttr.getValue().isPowerOf2()) {
+      emitWarning(simdOp->getLoc())
+          << "The specified alignment value, " << intAttr.getInt()
+          << " is not a power of two and will be ignored";
       continue;
+    }
 
     auto curInsert = builder.saveIP();
     builder.SetInsertPoint(sourceBlock);
diff --git a/mlir/test/Dialect/OpenMP/invalid.mlir b/mlir/test/Dialect/OpenMP/invalid.mlir
index cc9853ba4b72a..5088f2dfa7d7a 100644
--- a/mlir/test/Dialect/OpenMP/invalid.mlir
+++ b/mlir/test/Dialect/OpenMP/invalid.mlir
@@ -370,20 +370,6 @@ func.func @omp_simd_unexpected_alignment(%arg0 : index, %arg1 : index,
 
 // -----
 
-func.func @omp_simd_non_power_of_two_alignment(%arg0 : index, %arg1 : index,
-                                     %arg2 : index, %arg3 : memref<i32>,
-                                     %arg4 : memref<i32>) -> () {
-  //  expected-warning @below {{Alignment is not a power of 2, aligned clause will be ignored}}
-  "omp.simd"(%arg3, %arg4) ({
-    omp.loop_nest (%iv) : index = (%arg0) to (%arg1) step (%arg2) {
-      omp.yield
-    }
-  }) {alignments = [64, 127], operandSegmentSizes = array<i32: 2, 0, 0, 0, 0, 0, 0>} : (memref<i32>, memref<i32>) -> ()
-  return
-}
-
-// -----
-
 func.func @omp_simd_aligned_float(%arg0 : index, %arg1 : index,
                                   %arg2 : index, %arg3 : memref<i32>,
                                   %arg4 : memref<i32>) -> () {
diff --git a/mlir/test/Target/LLVMIR/openmp-simd-aligned.mlir b/mlir/test/Target/LLVMIR/openmp-simd-aligned.mlir
index 560c933e4dc2a..902548cb31d20 100644
--- a/mlir/test/Target/LLVMIR/openmp-simd-aligned.mlir
+++ b/mlir/test/Target/LLVMIR/openmp-simd-aligned.mlir
@@ -61,15 +61,19 @@ llvm.func @_QPsimd_aligned_allocatable() {
 
 //CHECK-LABEL: define void @_QPsimd_aligned_non_power_of_two() {
 //CHECK:   %[[A_ADDR:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, i64 1, align 8
+//CHECK:   %[[B_ADDR:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, i64 1, align 8
+//CHECK:   %[[LOAD_B:.*]] = load ptr, ptr %[[B_ADDR]], align 8
+//CHECK:   call void @llvm.assume(i1 true) [ "align"(ptr %[[LOAD_B]], i64 64) ]
 //CHECK-NOT:   call void @llvm.assume(i1 true) [ "align"(ptr %{{.*}}, i64 257) ]
 llvm.func @_QPsimd_aligned_non_power_of_two() {
   %0 = llvm.mlir.constant(1 : i64) : i64
   %1 = llvm.alloca %0 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)> {bindc_name = "a"} : (i64) -> !llvm.ptr
-  %2 = llvm.mlir.constant(1 : i32) : i32
-  %3 = llvm.mlir.constant(10 : i32) : i32
-  %4 = llvm.mlir.constant(1 : i32) : i32
-  omp.simd aligned(%1 : !llvm.ptr -> 257 : i64) {
-    omp.loop_nest (%arg0) : i32 = (%2) to (%3) inclusive step (%4) {
+  %2 = llvm.alloca %0 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)> {bindc_name = "b"} : (i64) -> !llvm.ptr
+  %3 = llvm.mlir.constant(1 : i32) : i32
+  %4 = llvm.mlir.constant(10 : i32) : i32
+  %5 = llvm.mlir.constant(1 : i32) : i32
+  omp.simd aligned(%1 : !llvm.ptr -> 257 : i64, %2 : !llvm.ptr -> 64 : i64) {
+    omp.loop_nest (%arg0) : i32 = (%3) to (%4) inclusive step (%5) {
       omp.yield
     }
   }



More information about the Mlir-commits mailing list