[PATCH] D45858: [DivRemPairs] Fix non-determinism in use list order.
Geoff Berry via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 24 19:21:23 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330792: [DivRemPairs] Fix non-determinism in use list order. (authored by gberry, committed by ).
Repository:
rL LLVM
https://reviews.llvm.org/D45858
Files:
llvm/trunk/lib/Transforms/Scalar/DivRemPairs.cpp
Index: llvm/trunk/lib/Transforms/Scalar/DivRemPairs.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/DivRemPairs.cpp
+++ llvm/trunk/lib/Transforms/Scalar/DivRemPairs.cpp
@@ -13,6 +13,8 @@
//===----------------------------------------------------------------------===//
#include "llvm/Transforms/Scalar/DivRemPairs.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/GlobalsModRef.h"
#include "llvm/Analysis/TargetTransformInfo.h"
@@ -48,7 +50,10 @@
// Insert all divide and remainder instructions into maps keyed by their
// operands and opcode (signed or unsigned).
- DenseMap<DivRemMapKey, Instruction *> DivMap, RemMap;
+ DenseMap<DivRemMapKey, Instruction *> DivMap;
+ // Use a MapVector for RemMap so that instructions are moved/inserted in a
+ // deterministic order.
+ MapVector<DivRemMapKey, Instruction *> RemMap;
for (auto &BB : F) {
for (auto &I : BB) {
if (I.getOpcode() == Instruction::SDiv)
@@ -67,14 +72,14 @@
// rare than division.
for (auto &RemPair : RemMap) {
// Find the matching division instruction from the division map.
- Instruction *DivInst = DivMap[RemPair.getFirst()];
+ Instruction *DivInst = DivMap[RemPair.first];
if (!DivInst)
continue;
// We have a matching pair of div/rem instructions. If one dominates the
// other, hoist and/or replace one.
NumPairs++;
- Instruction *RemInst = RemPair.getSecond();
+ Instruction *RemInst = RemPair.second;
bool IsSigned = DivInst->getOpcode() == Instruction::SDiv;
bool HasDivRemOp = TTI.hasDivRemOp(DivInst->getType(), IsSigned);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45858.143854.patch
Type: text/x-patch
Size: 1733 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180425/7d7303cf/attachment.bin>
More information about the llvm-commits
mailing list