[llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/binop-cast.ll cast-malloc.ll fpcast.ll setcc-cast-cast.ll zext.ll 2003-11-03-VarargsCallBug.ll 2006-10-19-SignedToUnsignedCastAndConst-2.ll 2006-10-19-SignedToUnsignedCastAndConst.ll call-cast-target.ll cast.ll cast_ptr.ll getelementptr_cast.ll getelementptr_index.ll narrow.ll

Reid Spencer reid at x10sys.com
Sun Nov 26 17:06:24 PST 2006



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

binop-cast.ll added (r1.1)
cast-malloc.ll added (r1.1)
fpcast.ll added (r1.1)
setcc-cast-cast.ll added (r1.1)
zext.ll added (r1.1)
2003-11-03-VarargsCallBug.ll updated: 1.1 -> 1.2
2006-10-19-SignedToUnsignedCastAndConst-2.ll updated: 1.1 -> 1.2
2006-10-19-SignedToUnsignedCastAndConst.ll updated: 1.1 -> 1.2
call-cast-target.ll updated: 1.1 -> 1.2
cast.ll updated: 1.31 -> 1.32
cast_ptr.ll updated: 1.1 -> 1.2
getelementptr_cast.ll updated: 1.1 -> 1.2
getelementptr_index.ll updated: 1.1 -> 1.2
narrow.ll updated: 1.2 -> 1.3
---
Log message:

For PR950: http://llvm.org/PR950 :
The long awaited CAST patch. This introduces 12 new instructions into LLVM
to replace the cast instruction. Corresponding changes throughout LLVM are
provided. This passes llvm-test, llvm/test, and SPEC CPUINT2000 with the
exception of 175.vpr which fails only on a slight floating point output
difference.


---
Diffs of the changes:  (+102 -17)

 2003-11-03-VarargsCallBug.ll                 |    2 -
 2006-10-19-SignedToUnsignedCastAndConst-2.ll |    2 -
 2006-10-19-SignedToUnsignedCastAndConst.ll   |    9 +++--
 binop-cast.ll                                |    7 ++++
 call-cast-target.ll                          |    2 -
 cast-malloc.ll                               |    8 +++++
 cast.ll                                      |    8 +++--
 cast_ptr.ll                                  |    2 -
 fpcast.ll                                    |   14 +++++++++
 getelementptr_cast.ll                        |    6 +--
 getelementptr_index.ll                       |    2 -
 narrow.ll                                    |    6 +--
 setcc-cast-cast.ll                           |   42 +++++++++++++++++++++++++++
 zext.ll                                      |    9 +++++
 14 files changed, 102 insertions(+), 17 deletions(-)


Index: llvm/test/Regression/Transforms/InstCombine/binop-cast.ll
diff -c /dev/null llvm/test/Regression/Transforms/InstCombine/binop-cast.ll:1.1
*** /dev/null	Sun Nov 26 19:05:21 2006
--- llvm/test/Regression/Transforms/InstCombine/binop-cast.ll	Sun Nov 26 19:05:10 2006
***************
*** 0 ****
--- 1,7 ----
+ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | notcast
+ 
+ uint %testAdd(int %X, int %Y) {
+ 	%tmp = add int %X, %Y
+ 	%tmp.l = sext int %tmp to uint
+ 	ret uint %tmp.l
+ }


Index: llvm/test/Regression/Transforms/InstCombine/cast-malloc.ll
diff -c /dev/null llvm/test/Regression/Transforms/InstCombine/cast-malloc.ll:1.1
*** /dev/null	Sun Nov 26 19:06:24 2006
--- llvm/test/Regression/Transforms/InstCombine/cast-malloc.ll	Sun Nov 26 19:05:10 2006
***************
*** 0 ****
--- 1,8 ----
+ ; test that casted mallocs get converted to malloc of the right type
+ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep bitcast
+ 
+ int* %test(uint %size) {
+ 	%X = malloc long, uint %size
+         %ret = bitcast long* %X to int*
+ 	ret int* %ret
+ }


Index: llvm/test/Regression/Transforms/InstCombine/fpcast.ll
diff -c /dev/null llvm/test/Regression/Transforms/InstCombine/fpcast.ll:1.1
*** /dev/null	Sun Nov 26 19:06:24 2006
--- llvm/test/Regression/Transforms/InstCombine/fpcast.ll	Sun Nov 26 19:05:10 2006
***************
*** 0 ****
--- 1,14 ----
+ ; Test some floating point casting cases
+ ; RUN: llvm-as %s -o - | opt -instcombine | llvm-dis | notcast
+ ; RUN: llvm-as %s -o - | opt -instcombine | llvm-dis | \
+ ; RUN:   grep 'ret [us]byte \(-1\)\|\(255\)'
+ 
+ sbyte %test() {
+     %x = fptoui float 255.0 to sbyte 
+     ret sbyte %x
+ }
+ 
+ ubyte %test() {
+     %x = fptosi float -1.0 to ubyte
+     ret ubyte %x
+ }


Index: llvm/test/Regression/Transforms/InstCombine/setcc-cast-cast.ll
diff -c /dev/null llvm/test/Regression/Transforms/InstCombine/setcc-cast-cast.ll:1.1
*** /dev/null	Sun Nov 26 19:06:24 2006
--- llvm/test/Regression/Transforms/InstCombine/setcc-cast-cast.ll	Sun Nov 26 19:05:10 2006
***************
*** 0 ****
--- 1,42 ----
+ ; This test case was reduced from MultiSource/Applications/hbd. It makes sure
+ ; that folding doesn't happen in case a zext is applied where a sext should have
+ ; been when a setcc is used with two casts.
+ ; RUN: llvm-as < %s | llc -instcombine | llvm-dis | not grep 'br bool false'
+ int %bug(ubyte %inbuff) {
+ entry:
+ 	%tmp = bitcast ubyte %inbuff to sbyte   ; <sbyte> [#uses=1]
+ 	%tmp = sext sbyte %tmp to int		; <int> [#uses=3]
+ 	%tmp = seteq int %tmp, 1		; <bool> [#uses=1]
+ 	br bool %tmp, label %cond_true, label %cond_next
+ 
+ cond_true:		; preds = %entry
+ 	br label %bb
+ 
+ cond_next:		; preds = %entry
+ 	%tmp3 = seteq int %tmp, -1		; <bool> [#uses=1]
+ 	br bool %tmp3, label %cond_true4, label %cond_next5
+ 
+ cond_true4:		; preds = %cond_next
+ 	br label %bb
+ 
+ cond_next5:		; preds = %cond_next
+ 	%tmp7 = setgt int %tmp, 1		; <bool> [#uses=1]
+ 	br bool %tmp7, label %cond_true8, label %cond_false
+ 
+ cond_true8:		; preds = %cond_next5
+ 	br label %cond_next9
+ 
+ cond_false:		; preds = %cond_next5
+ 	br label %cond_next9
+ 
+ cond_next9:		; preds = %cond_false, %cond_true8
+ 	%iftmp.1.0 = phi int [ 42, %cond_true8 ], [ 23, %cond_false ]		; <int> [#uses=1]
+ 	br label %return
+ 
+ bb:		; preds = %cond_true4, %cond_true
+ 	br label %return
+ 
+ return:		; preds = %bb, %cond_next9
+ 	%retval.0 = phi int [ 17, %bb ], [ %iftmp.1.0, %cond_next9 ]		; <int> [#uses=1]
+ 	ret int %retval.0
+ }


Index: llvm/test/Regression/Transforms/InstCombine/zext.ll
diff -c /dev/null llvm/test/Regression/Transforms/InstCombine/zext.ll:1.1
*** /dev/null	Sun Nov 26 19:06:24 2006
--- llvm/test/Regression/Transforms/InstCombine/zext.ll	Sun Nov 26 19:05:10 2006
***************
*** 0 ****
--- 1,9 ----
+ ; Tests to make sure elimination of casts is working correctly
+ ; RUN: llvm-as < %s | opt -instcombine -disable-output &&
+ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | notcast '' '%c1.*'
+ 
+ long %test_sext_zext(short %A) {
+     %c1 = zext short %A to uint
+     %c2 = sext uint %c1 to long
+     ret long %c2
+ }


Index: llvm/test/Regression/Transforms/InstCombine/2003-11-03-VarargsCallBug.ll
diff -u llvm/test/Regression/Transforms/InstCombine/2003-11-03-VarargsCallBug.ll:1.1 llvm/test/Regression/Transforms/InstCombine/2003-11-03-VarargsCallBug.ll:1.2
--- llvm/test/Regression/Transforms/InstCombine/2003-11-03-VarargsCallBug.ll:1.1	Mon Nov  3 12:33:44 2003
+++ llvm/test/Regression/Transforms/InstCombine/2003-11-03-VarargsCallBug.ll	Sun Nov 26 19:05:10 2006
@@ -1,5 +1,5 @@
 ; The cast in this testcase is not eliminatable on a 32-bit target!
-; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep cast
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep inttoptr
 
 target endian = little
 target pointersize = 32


Index: llvm/test/Regression/Transforms/InstCombine/2006-10-19-SignedToUnsignedCastAndConst-2.ll
diff -u llvm/test/Regression/Transforms/InstCombine/2006-10-19-SignedToUnsignedCastAndConst-2.ll:1.1 llvm/test/Regression/Transforms/InstCombine/2006-10-19-SignedToUnsignedCastAndConst-2.ll:1.2
--- llvm/test/Regression/Transforms/InstCombine/2006-10-19-SignedToUnsignedCastAndConst-2.ll:1.1	Thu Oct 19 15:59:13 2006
+++ llvm/test/Regression/Transforms/InstCombine/2006-10-19-SignedToUnsignedCastAndConst-2.ll	Sun Nov 26 19:05:10 2006
@@ -1,5 +1,5 @@
 ; The optimizer should be able to remove cast operation here.
-; RUN: llvm-as %s -o - | opt -instcombine | llvm-dis | not grep 'cast.*int'
+; RUN: llvm-as %s -o - | opt -instcombine | llvm-dis | not grep 'sext.*int'
 
 bool %eq_signed_to_small_unsigned(sbyte %SB) {
    %Y = cast sbyte %SB to uint         ; <uint> [#uses=1]


Index: llvm/test/Regression/Transforms/InstCombine/2006-10-19-SignedToUnsignedCastAndConst.ll
diff -u llvm/test/Regression/Transforms/InstCombine/2006-10-19-SignedToUnsignedCastAndConst.ll:1.1 llvm/test/Regression/Transforms/InstCombine/2006-10-19-SignedToUnsignedCastAndConst.ll:1.2
--- llvm/test/Regression/Transforms/InstCombine/2006-10-19-SignedToUnsignedCastAndConst.ll:1.1	Thu Oct 19 13:54:08 2006
+++ llvm/test/Regression/Transforms/InstCombine/2006-10-19-SignedToUnsignedCastAndConst.ll	Sun Nov 26 19:05:10 2006
@@ -1,8 +1,9 @@
 ; This test case is reduced from llvmAsmParser.cpp
 ; The optimizer should not remove the cast here.
-; RUN: llvm-as %s -o - | opt -instcombine | llvm-dis | grep 'cast.*int'
+; RUN: llvm-as %s -o - | opt -instcombine | llvm-dis | grep 'sext.*int'
+
 bool %test(short %X) {
-%A = cast short %X to uint
-%B = setgt uint %A, 1330
-ret bool %B
+    %A = cast short %X to uint
+    %B = setgt uint %A, 1330
+    ret bool %B
 }


Index: llvm/test/Regression/Transforms/InstCombine/call-cast-target.ll
diff -u llvm/test/Regression/Transforms/InstCombine/call-cast-target.ll:1.1 llvm/test/Regression/Transforms/InstCombine/call-cast-target.ll:1.2
--- llvm/test/Regression/Transforms/InstCombine/call-cast-target.ll:1.1	Thu Apr 20 09:54:17 2006
+++ llvm/test/Regression/Transforms/InstCombine/call-cast-target.ll	Sun Nov 26 19:05:10 2006
@@ -1,4 +1,4 @@
-; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep call | not grep cast
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep call | not grep bitcast
 
 target endian = little
 target pointersize = 32


Index: llvm/test/Regression/Transforms/InstCombine/cast.ll
diff -u llvm/test/Regression/Transforms/InstCombine/cast.ll:1.31 llvm/test/Regression/Transforms/InstCombine/cast.ll:1.32
--- llvm/test/Regression/Transforms/InstCombine/cast.ll:1.31	Sun Oct  1 14:39:45 2006
+++ llvm/test/Regression/Transforms/InstCombine/cast.ll	Sun Nov 26 19:05:10 2006
@@ -1,6 +1,6 @@
 ; Tests to make sure elimination of casts is working correctly
 ; RUN: llvm-as < %s | opt -instcombine -disable-output &&
-; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep '%c' | not grep cast
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep '%c' | notcast
 
 %inbuf = external global [32832 x ubyte]
 
@@ -104,7 +104,6 @@
 	ret bool %c
 }
 
-
 short %test17(bool %tmp3) {
 	%c = cast bool %tmp3 to int
 	%t86 = cast int %c to short
@@ -207,3 +206,8 @@
         ret void
 }
 
+uint %test33(uint %c1) {
+        %x = bitcast uint %c1 to float 
+        %y = bitcast float %x to uint
+        ret uint %y
+}


Index: llvm/test/Regression/Transforms/InstCombine/cast_ptr.ll
diff -u llvm/test/Regression/Transforms/InstCombine/cast_ptr.ll:1.1 llvm/test/Regression/Transforms/InstCombine/cast_ptr.ll:1.2
--- llvm/test/Regression/Transforms/InstCombine/cast_ptr.ll:1.1	Tue Sep 19 13:23:39 2006
+++ llvm/test/Regression/Transforms/InstCombine/cast_ptr.ll	Sun Nov 26 19:05:10 2006
@@ -1,6 +1,6 @@
 ; Tests to make sure elimination of casts is working correctly
 ; RUN: llvm-as < %s | opt -instcombine -disable-output &&
-; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep cast
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep '\([sz]ext\)\|\(trunc\)'
 
 target pointersize = 32
 


Index: llvm/test/Regression/Transforms/InstCombine/getelementptr_cast.ll
diff -u llvm/test/Regression/Transforms/InstCombine/getelementptr_cast.ll:1.1 llvm/test/Regression/Transforms/InstCombine/getelementptr_cast.ll:1.2
--- llvm/test/Regression/Transforms/InstCombine/getelementptr_cast.ll:1.1	Sat Nov 27 11:55:20 2004
+++ llvm/test/Regression/Transforms/InstCombine/getelementptr_cast.ll	Sun Nov 26 19:05:10 2006
@@ -1,9 +1,9 @@
-; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep 'getelementptr.*cast'
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | notcast '' 'getelementptr.*'
 %G = external global [3 x sbyte]
 
 implementation
 
 ubyte *%foo(uint %Idx) {
-%tmp = getelementptr ubyte* cast ([3 x sbyte]* %G to ubyte*), uint %Idx
-ret ubyte* %tmp
+    %tmp = getelementptr ubyte* cast ([3 x sbyte]* %G to ubyte*), uint %Idx
+    ret ubyte* %tmp
 }


Index: llvm/test/Regression/Transforms/InstCombine/getelementptr_index.ll
diff -u llvm/test/Regression/Transforms/InstCombine/getelementptr_index.ll:1.1 llvm/test/Regression/Transforms/InstCombine/getelementptr_index.ll:1.2
--- llvm/test/Regression/Transforms/InstCombine/getelementptr_index.ll:1.1	Wed Apr  7 13:38:01 2004
+++ llvm/test/Regression/Transforms/InstCombine/getelementptr_index.ll	Sun Nov 26 19:05:10 2006
@@ -1,4 +1,4 @@
-; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep cast
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep trunc
 
 target endian = little
 target pointersize = 32


Index: llvm/test/Regression/Transforms/InstCombine/narrow.ll
diff -u llvm/test/Regression/Transforms/InstCombine/narrow.ll:1.2 llvm/test/Regression/Transforms/InstCombine/narrow.ll:1.3
--- llvm/test/Regression/Transforms/InstCombine/narrow.ll:1.2	Sun May  7 13:16:31 2006
+++ llvm/test/Regression/Transforms/InstCombine/narrow.ll	Sun Nov 26 19:05:10 2006
@@ -8,10 +8,10 @@
 ;
 bool %test1(int %A, int %B) {
         %C1 = setlt int %A, %B
-        %ELIM1 = cast bool %C1 to uint
+        %ELIM1 = zext bool %C1 to uint
         %C2 = setgt int %A, %B
-        %ELIM2 = cast bool %C2 to uint
+        %ELIM2 = zext bool %C2 to uint
         %C3 = and uint %ELIM1, %ELIM2
-        %ELIM3 = cast uint %C3 to bool
+        %ELIM3 = trunc uint %C3 to bool
         ret bool %ELIM3
 }






More information about the llvm-commits mailing list