This patch fixes bugs that were exposed by r237046 ( http://reviews.llvm.org/rL237046 ):
- When replacing a division node, it's not enough to RAUW. We should call CombineTo() to delete dead nodes and combine again.
- Because we are changing the DAG, we can't return an empty SDValue after the transform. As the code comments say:
Visitation implementation - Implement dag node combining for different node types. The semantics are as follows: Return Value: SDValue.getNode() == 0 - No change was made SDValue.getNode() == N - N was replaced, is dead and has been handled. otherwise - N should be replaced by the returned Operand.
The new test case shows no difference with or without this patch, but it will crash if we re-apply r237046. If anyone sees a way to expose the bug without FMF, I'd be happy to modify the test case.