Merge "Skip loop optimization if there is no loop in the graph."