[llvm-commits] CVS: llvm/test/Regression/Transforms/IndVarsSimplify/lftr_simple.llx tripcount_compute.llx tripcount_infinite.llx

Chris Lattner lattner at cs.uiuc.edu
Fri Apr 2 14:46:46 PST 2004


Changes in directory llvm/test/Regression/Transforms/IndVarsSimplify:

lftr_simple.llx added (r1.1)
tripcount_compute.llx added (r1.1)
tripcount_infinite.llx added (r1.1)

---
Log message:

New testcases for the indvars pass


---
Diffs of the changes:  (+145 -0)

Index: llvm/test/Regression/Transforms/IndVarsSimplify/lftr_simple.llx
diff -c /dev/null llvm/test/Regression/Transforms/IndVarsSimplify/lftr_simple.llx:1.1
*** /dev/null	Fri Apr  2 14:26:14 2004
--- llvm/test/Regression/Transforms/IndVarsSimplify/lftr_simple.llx	Fri Apr  2 14:26:04 2004
***************
*** 0 ****
--- 1,23 ----
+ ; LFTR should eliminate the need for the computation of i*i completely.  It 
+ ; is only used to compute the exit value.
+ ; RUN: llvm-as < %s | opt -indvars -dce | llvm-dis | not grep mul
+ 
+ %A = external global int
+ 
+ implementation
+ 
+ int %quadratic_setlt() {   ;; for (i = 7; i*i < 1000; ++i)
+ entry:
+         br label %loop
+ loop:
+         %i = phi int [ 7, %entry ], [ %i.next, %loop ]
+         %i.next = add int %i, 1
+ 	store int %i, int* %A
+ 	
+         %i2 = mul int %i, %i
+         %c = setlt int %i2, 1000
+         br bool %c, label %loop, label %loopexit
+ loopexit:
+         ret int %i
+ }
+ 


Index: llvm/test/Regression/Transforms/IndVarsSimplify/tripcount_compute.llx
diff -c /dev/null llvm/test/Regression/Transforms/IndVarsSimplify/tripcount_compute.llx:1.1
*** /dev/null	Fri Apr  2 14:26:14 2004
--- llvm/test/Regression/Transforms/IndVarsSimplify/tripcount_compute.llx	Fri Apr  2 14:26:04 2004
***************
*** 0 ****
--- 1,90 ----
+ ; These tests ensure that we can compute the trip count of various forms of 
+ ; loops.  If the trip count of the loop is computable, then we will know what
+ ; the exit value of the loop will be for some value, allowing us to substitute
+ ; it directly into users outside of the loop, making the loop dead.
+ ;
+ ; RUN: llvm-as < %s | opt -indvars -adce -simplifycfg | llvm-dis | not grep br
+ 
+ int %linear_setne() {   ;; for (i = 0; i != 100; ++i)
+ entry:
+ 	br label %loop
+ loop:
+ 	%i = phi int [ 0, %entry ], [ %i.next, %loop ]
+ 	%i.next = add int %i, 1
+ 	%c = setne int %i, 100
+ 	br bool %c, label %loop, label %loopexit
+ loopexit:
+ 	ret int %i
+ }
+ 
+ int %linear_setne_2() {   ;; for (i = 0; i != 100; i += 2)
+ entry:
+ 	br label %loop
+ loop:
+ 	%i = phi int [ 0, %entry ], [ %i.next, %loop ]
+ 	%i.next = add int %i, 2
+ 	%c = setne int %i, 100
+ 	br bool %c, label %loop, label %loopexit
+ loopexit:
+ 	ret int %i
+ }
+ 
+ 
+ int %linear_setne_overflow() {   ;; for (i = 1024; i != 0; i += 1024)
+ entry:
+ 	br label %loop
+ loop:
+ 	%i = phi int [ 1024, %entry ], [ %i.next, %loop ]
+ 	%i.next = add int %i, 1024
+ 	%c = setne int %i, 0
+ 	br bool %c, label %loop, label %loopexit
+ loopexit:
+ 	ret int %i
+ }
+ 
+ int %linear_setlt() {   ;; for (i = 0; i < 100; ++i)
+ entry:
+ 	br label %loop
+ loop:
+ 	%i = phi int [ 0, %entry ], [ %i.next, %loop ]
+ 	%i.next = add int %i, 1
+ 	%c = setlt int %i, 100
+ 	br bool %c, label %loop, label %loopexit
+ loopexit:
+ 	ret int %i
+ }
+ 
+ int %quadratic_setlt() {   ;; for (i = 7; i*i < 1000; i+=3)
+ entry:
+         br label %loop
+ loop:
+         %i = phi int [ 7, %entry ], [ %i.next, %loop ]
+         %i.next = add int %i, 3
+         %i2 = mul int %i, %i
+         %c = setlt int %i2, 1000
+         br bool %c, label %loop, label %loopexit
+ loopexit:
+         ret int %i
+ }
+ 
+ ;; Chained loop test - The exit value of the second loop depends on the exit
+ ;; value of the first being computed.
+ int %chained() {
+ entry:
+ 	br label %loop
+ loop:   ;; for (i = 0; i != 100; ++i)
+ 	%i = phi int [ 0, %entry ], [ %i.next, %loop ]
+ 	%i.next = add int %i, 1
+ 	%c = setne int %i, 100
+ 	br bool %c, label %loop, label %loopexit
+ loopexit:
+ 	br label %loop2
+ loop2:  ;; for (j = i; j != 200; ++j)
+ 	%j = phi int [ %i, %loopexit ], [ %j.next, %loop2 ]
+ 	%j.next = add int %j, 1
+ 	%c2 = setne int %j, 200
+ 	br bool %c2, label %loop2, label %loopexit2
+ loopexit2:
+ 	ret int %j
+ }
+ 


Index: llvm/test/Regression/Transforms/IndVarsSimplify/tripcount_infinite.llx
diff -c /dev/null llvm/test/Regression/Transforms/IndVarsSimplify/tripcount_infinite.llx:1.1
*** /dev/null	Fri Apr  2 14:26:14 2004
--- llvm/test/Regression/Transforms/IndVarsSimplify/tripcount_infinite.llx	Fri Apr  2 14:26:04 2004
***************
*** 0 ****
--- 1,32 ----
+ ; These tests have an infinite trip count.  We obviously shouldn't remove the 
+ ; loops!  :)
+ ;
+ ; RUN: llvm-as < %s | opt -indvars -adce -simplifycfg | llvm-dis | grep set | wc -l > %t2
+ ; RUN: llvm-as < %s | llvm-dis | grep set | wc -l > %t1
+ ; RUN: diff %t1 %t2
+ 
+ int %infinite_linear() {   ;; test for (i = 1; i != 100; i += 2)
+ entry:
+         br label %loop
+ loop:
+         %i = phi int [ 1, %entry ], [ %i.next, %loop ]
+         %i.next = add int %i, 2
+         %c = setne int %i, 100
+         br bool %c, label %loop, label %loopexit
+ loopexit:
+         ret int %i
+ }
+ 
+ int %infinite_quadratic() {   ;; test for (i = 1; i*i != 63; ++i)
+ entry:
+         br label %loop
+ loop:
+         %i = phi int [ 1, %entry ], [ %i.next, %loop ]
+ 	%isquare = mul int %i, %i
+         %i.next = add int %i, 1
+         %c = setne int %isquare, 63
+         br bool %c, label %loop, label %loopexit
+ loopexit:
+         ret int %i
+ }
+ 





More information about the llvm-commits mailing list