[Differential] D80116: [IR] Simplify Use::swap. NFCI.
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 21 04:15:42 PDT 2020
This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5e5bda74b61b: [IR] Simplify Use::swap. NFCI. (authored by foad).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80116/new/
https://reviews.llvm.org/D80116
Files:
llvm/lib/IR/Use.cpp
llvm/test/Transforms/LoopReroll/nonconst_lb.ll
Index: llvm/test/Transforms/LoopReroll/nonconst_lb.ll
===================================================================
--- llvm/test/Transforms/LoopReroll/nonconst_lb.ll
+++ llvm/test/Transforms/LoopReroll/nonconst_lb.ll
@@ -48,7 +48,7 @@
ret void
}
; CHECK-LABEL: @foo
-; CHECK: for.body.preheader: ; preds = %entry
+; CHECK: for.body.preheader:
; CHECK: %0 = add i32 %n, -1
; CHECK: %1 = sub i32 %0, %m
; CHECK: %2 = lshr i32 %1, 2
@@ -56,7 +56,7 @@
; CHECK: %4 = add i32 %3, 3
; CHECK: br label %for.body
-; CHECK: for.body: ; preds = %for.body, %for.body.preheader
+; CHECK: for.body:
; CHECK: %indvar = phi i32 [ 0, %for.body.preheader ], [ %indvar.next, %for.body ]
; CHECK: %5 = add i32 %m, %indvar
; CHECK: %arrayidx = getelementptr inbounds i32, i32* %B, i32 %5
Index: llvm/lib/IR/Use.cpp
===================================================================
--- llvm/lib/IR/Use.cpp
+++ llvm/lib/IR/Use.cpp
@@ -17,24 +17,17 @@
if (Val == RHS.Val)
return;
- if (Val)
- removeFromList();
-
- Value *OldVal = Val;
- if (RHS.Val) {
- RHS.removeFromList();
- Val = RHS.Val;
- Val->addUse(*this);
- } else {
- Val = nullptr;
- }
-
- if (OldVal) {
- RHS.Val = OldVal;
- RHS.Val->addUse(RHS);
- } else {
- RHS.Val = nullptr;
- }
+ std::swap(Val, RHS.Val);
+ std::swap(Next, RHS.Next);
+ std::swap(Prev, RHS.Prev);
+
+ *Prev = this;
+ if (Next)
+ Next->Prev = &Next;
+
+ *RHS.Prev = &RHS;
+ if (RHS.Next)
+ RHS.Next->Prev = &RHS.Next;
}
unsigned Use::getOperandNo() const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80116.279046.patch
Type: text/x-patch
Size: 1635 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200721/ade29d4c/attachment.bin>
More information about the llvm-commits
mailing list