Here is my stab at D3DXWeldVertices in one big patch. It implements most of the case I could think of except for attribute sorting (which I don't completely understand how works).
I have also attached a test case for attribute sorting as a separate patch. I do not intend to submit that test case because it cannot easily be made into a todo_wine without producing "succeeded inside todo block" messages. It is simply here for reference if someone later wants to implement it. I did not implement attribute sorting because I think it might require some changes to OptimizeInPlace, which I already use for compacting the mesh and building the vertex_remap array.