[Mlir-commits] [mlir] 4445ed4 - [OpenMP][MLIR] Fix llvm::sort comparator. (#91963)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon May 13 06:58:02 PDT 2024


Author: Oleg Shyshkov
Date: 2024-05-13T15:57:57+02:00
New Revision: 4445ed4244cd00981a04b1f461128ed4c47c1dec

URL: https://github.com/llvm/llvm-project/commit/4445ed4244cd00981a04b1f461128ed4c47c1dec
DIFF: https://github.com/llvm/llvm-project/commit/4445ed4244cd00981a04b1f461128ed4c47c1dec.diff

LOG: [OpenMP][MLIR] Fix llvm::sort comparator. (#91963)

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.

Added: 
    

Modified: 
    mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index 282e640d3aaad..a7294632d6667 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -2155,18 +2155,15 @@ 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;


        


More information about the Mlir-commits mailing list