As the body moves in a vertical semicircle from its lowest to the highest point, net displacement is equal to 2r. The only force acting is gravity in vertical direction i.e., the direction of displacement. So total work done = force due to gravity × net displacement = mg × 2r = 2mgr.