[Mlir-commits] [mlir] [OpenMP][MLIR] Fix llvm::sort comparator. (PR #91963)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon May 13 06:34:39 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-openmp
Author: Oleg Shyshkov (olegshyshkov)
<details>
<summary>Changes</summary>
The current comparator doesn't work correctly when two identical entries with -1 are compared. The comparator returns `first` is case when `aIndex == -1 && bIndex == -1`, but it should `continue` as those indexes are the same.
---
Full diff: https://github.com/llvm/llvm-project/pull/91963.diff
1 Files Affected:
- (modified) mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp (+2-6)
``````````diff
diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index 282e640d3aaad..2928900e40bd6 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -2155,18 +2155,14 @@ getFirstOrLastMappedMemberPtr(mlir::omp::MapInfoOp mapInfo, bool first) {
int aIndex = indexValues[a * shape[1] + i];
int bIndex = indexValues[b * shape[1] + i];
+ if (aIndex == bIndex) continue;
+
if (aIndex != -1 && bIndex == -1)
return false;
if (aIndex == -1 && bIndex != -1)
return true;
- if (aIndex == -1)
- return first;
-
- if (bIndex == -1)
- return !first;
-
// A is earlier in the record type layout than B
if (aIndex < bIndex)
return first;
``````````
</details>
https://github.com/llvm/llvm-project/pull/91963
More information about the Mlir-commits
mailing list