In this paper, the gravity dam whose foundation gently inclines and weak plane is the outcrop has been taken as the research object, in view of the problem that some downstream bedrock may slip caused by its shearing, here's a way to provide a calculation method solving the double inclined sliding critical failure surface. This article takes the location variable of the shear failure surface of downstream bedrock as the optimization variable, takes the deep anti slide safety factor of gravity dam as the objective function, and takes the equal safety coefficient method equation as the constrain condition, then establish the nonlinear mathematical programming model of stability analysis for deep anti slide of gravity dam, and the mathematical programming optimization algorithm is used to solve location of the most critical damage slip surface of the downstream rock and the minimum value of its corresponding safety factors. This method has a clear concept, and high accuracy, which can be applied to the stability analysis of deep anti slide of gravity dam.