[PATCH] D48364: [DAG] Don't map a TableId to itself in the ReplacedValues map
Bjorn Pettersson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 20 09:10:49 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL335141: [DAG] Don't map a TableId to itself in the ReplacedValues map (authored by bjope, committed by ).
Repository:
rL LLVM
https://reviews.llvm.org/D48364
Files:
llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h
llvm/trunk/test/CodeGen/X86/legalize-types-remapid.ll
Index: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
@@ -575,6 +575,7 @@
void DAGTypeLegalizer::RemapId(TableId &Id) {
auto I = ReplacedValues.find(Id);
if (I != ReplacedValues.end()) {
+ assert(Id != I->second && "Id is mapped to itself.");
// Use path compression to speed up future lookups if values get multiply
// replaced with other values.
RemapId(I->second);
@@ -652,7 +653,8 @@
auto FromId = getTableId(From);
auto ToId = getTableId(To);
- ReplacedValues[FromId] = ToId;
+ if (FromId != ToId)
+ ReplacedValues[FromId] = ToId;
DAG.ReplaceAllUsesOfValueWith(From, To);
// Process the list of nodes that need to be reanalyzed.
@@ -685,7 +687,8 @@
auto OldValId = getTableId(OldVal);
auto NewValId = getTableId(NewVal);
DAG.ReplaceAllUsesOfValueWith(OldVal, NewVal);
- ReplacedValues[OldValId] = NewValId;
+ if (OldValId != NewValId)
+ ReplacedValues[OldValId] = NewValId;
}
// The original node continues to exist in the DAG, marked NewNode.
}
Index: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h
===================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h
@@ -186,7 +186,8 @@
TableId NewId = getTableId(SDValue(New, i));
TableId OldId = getTableId(SDValue(Old, i));
- ReplacedValues[OldId] = NewId;
+ if (OldId != NewId)
+ ReplacedValues[OldId] = NewId;
// Delete Node from tables.
ValueToIdMap.erase(SDValue(Old, i));
Index: llvm/trunk/test/CodeGen/X86/legalize-types-remapid.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/legalize-types-remapid.ll
+++ llvm/trunk/test/CodeGen/X86/legalize-types-remapid.ll
@@ -0,0 +1,16 @@
+; RUN: llc -mtriple=i386 -mcpu=generic -O0 -o /dev/null %s
+
+ at c = global i32 0
+ at d = global <2 x i64> zeroinitializer
+
+define void @test() {
+bb1:
+ %t0 = load <2 x i64>, <2 x i64>* @d
+ %t0.i0 = extractelement <2 x i64> %t0, i32 0
+ %t0.i0.cast = bitcast i64 %t0.i0 to <2 x i32>
+ %t0.i0.cast.i0 = extractelement <2 x i32> %t0.i0.cast, i32 0
+ store volatile i32 %t0.i0.cast.i0, i32* @c
+ %t0.i0.cast.i1 = extractelement <2 x i32> %t0.i0.cast, i32 1
+ store volatile i32 %t0.i0.cast.i1, i32* @c
+ ret void
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48364.152103.patch
Type: text/x-patch
Size: 2624 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180620/86d0ae70/attachment.bin>
More information about the llvm-commits
mailing list