Skip to content

Commit 4445ed4

Browse files
authored
[OpenMP][MLIR] Fix llvm::sort comparator. (llvm#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.
1 parent 13cd881 commit 4445ed4

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,18 +2155,15 @@ getFirstOrLastMappedMemberPtr(mlir::omp::MapInfoOp mapInfo, bool first) {
21552155
int aIndex = indexValues[a * shape[1] + i];
21562156
int bIndex = indexValues[b * shape[1] + i];
21572157

2158+
if (aIndex == bIndex)
2159+
continue;
2160+
21582161
if (aIndex != -1 && bIndex == -1)
21592162
return false;
21602163

21612164
if (aIndex == -1 && bIndex != -1)
21622165
return true;
21632166

2164-
if (aIndex == -1)
2165-
return first;
2166-
2167-
if (bIndex == -1)
2168-
return !first;
2169-
21702167
// A is earlier in the record type layout than B
21712168
if (aIndex < bIndex)
21722169
return first;

0 commit comments

Comments
 (0)