Skip to content

Commit f5be1ff

Browse files
committed
[OpenMP][MLIR] Fix llvm::sort comparator.
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 f5be1ff

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,18 +2155,14 @@ 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) continue;
2159+
21582160
if (aIndex != -1 && bIndex == -1)
21592161
return false;
21602162

21612163
if (aIndex == -1 && bIndex != -1)
21622164
return true;
21632165

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

0 commit comments

Comments
 (0)