Software pipelining tries to improve the performance of a loop by overlapping the execution of several successive iterations. Modulo scheduling is a kind of widely used scheduling technique. The drawbacks of software pipelining, such as increased register pressure, would sometimes degrade the performance improvement that software pipelining gains. This kind of cost varies with the processor architecture, compiler optimization, and characteristics of programs. In this paper, a program characteristics oriented cost model for software pipelining is proposed, and the cost is evaluated in some aspects. A dependency based cost testing (DBCT) algorithm is developed to provide information for the compiler to decide whether to apply software pipelining or not. Experimental results show that DBCT algorithm boosts performance greatly.