Fix HInstruction::ReplaceInput(), allow no-op.

Allow HInstruction::ReplaceInput() to be called with
a `replacement` being the same as the old input and
do nothing in that case.

This is a follow-up to
    https://android-review.googlesource.com/216923
where I erroneously assumed that it never happens.

Also adhere to the standard C++ std::forward_list<>
semantics in the single-element overload of
`IntrusiveForwardList<>::splice_after()`.

Bug: 28173563
Change-Id: I5cea14c212b1083f90ffe6b5b53324ad663d57d8
diff --git a/compiler/utils/intrusive_forward_list.h b/compiler/utils/intrusive_forward_list.h
index a90b0f5..ec2c087 100644
--- a/compiler/utils/intrusive_forward_list.h
+++ b/compiler/utils/intrusive_forward_list.h
@@ -221,6 +221,13 @@
   }
   // Splice the element after `i`.
   void splice_after(const_iterator position, IntrusiveForwardList& src, const_iterator i) {
+    // The standard specifies that this version does nothing if `position == i`
+    // or `position == ++i`. We must handle the latter here because the overload
+    // `splice_after(position, src, first, last)` does not allow `position` inside
+    // the range `(first, last)`.
+    if (++const_iterator(i) == position) {
+      return;
+    }
     const_iterator last = i;
     std::advance(last, 2);
     splice_after(position, src, i, last);