aboutsummaryrefslogtreecommitdiff
path: root/test/Transforms
diff options
context:
space:
mode:
Diffstat (limited to 'test/Transforms')
-rw-r--r--test/Transforms/IPConstantProp/return-constant.ll2
-rw-r--r--test/Transforms/Inline/casts.ll20
-rw-r--r--test/Transforms/InstCombine/2003-11-03-VarargsCallBug.ll2
-rw-r--r--test/Transforms/InstCombine/2006-10-19-SignedToUnsignedCastAndConst-2.ll2
-rw-r--r--test/Transforms/InstCombine/2006-10-19-SignedToUnsignedCastAndConst.ll9
-rw-r--r--test/Transforms/InstCombine/binop-cast.ll7
-rw-r--r--test/Transforms/InstCombine/call-cast-target.ll2
-rw-r--r--test/Transforms/InstCombine/cast-malloc.ll8
-rw-r--r--test/Transforms/InstCombine/cast.ll8
-rw-r--r--test/Transforms/InstCombine/cast_ptr.ll2
-rw-r--r--test/Transforms/InstCombine/fpcast.ll14
-rw-r--r--test/Transforms/InstCombine/getelementptr_cast.ll6
-rw-r--r--test/Transforms/InstCombine/getelementptr_index.ll2
-rw-r--r--test/Transforms/InstCombine/narrow.ll6
-rw-r--r--test/Transforms/InstCombine/setcc-cast-cast.ll42
-rw-r--r--test/Transforms/InstCombine/zext.ll9
-rw-r--r--test/Transforms/LevelRaise/2002-03-21-MissedRaise.ll6
-rw-r--r--test/Transforms/LevelRaise/2002-03-21-MissedRaise2.ll2
-rw-r--r--test/Transforms/LevelRaise/2002-03-21-MissedRaise3.ll2
-rw-r--r--test/Transforms/LevelRaise/2002-04-16-MissedRaise.ll2
-rw-r--r--test/Transforms/LevelRaise/2002-05-02-MissedRaise.ll2
-rw-r--r--test/Transforms/LevelRaise/2002-05-10-LoadPeephole.ll2
-rw-r--r--test/Transforms/LevelRaise/2002-05-23-MissedRaise.ll2
-rw-r--r--test/Transforms/LevelRaise/2002-07-16-MissedRaise.ll2
-rw-r--r--test/Transforms/LevelRaise/2002-07-18-MissedAllocaRaise.ll2
25 files changed, 134 insertions, 29 deletions
diff --git a/test/Transforms/IPConstantProp/return-constant.ll b/test/Transforms/IPConstantProp/return-constant.ll
index a3e2832c5e..f779d76af1 100644
--- a/test/Transforms/IPConstantProp/return-constant.ll
+++ b/test/Transforms/IPConstantProp/return-constant.ll
@@ -11,6 +11,6 @@ F:
bool %caller(bool %C) {
%X = call int %foo(bool %C)
- %Y = cast int %X to bool
+ %Y = trunc int %X to bool
ret bool %Y
}
diff --git a/test/Transforms/Inline/casts.ll b/test/Transforms/Inline/casts.ll
new file mode 100644
index 0000000000..8b597adca0
--- /dev/null
+++ b/test/Transforms/Inline/casts.ll
@@ -0,0 +1,20 @@
+; RUN: llvm-as < %s | opt -inline | llvm-dis | grep 'ret int 1'
+; ModuleID = 'short.opt.bc'
+
+implementation ; Functions:
+
+int %testBool(bool %X) {
+ %tmp = zext bool %X to int ; <int> [#uses=1]
+ ret int %tmp
+}
+
+int %testByte(sbyte %X) {
+ %tmp = setne sbyte %X, 0 ; <bool> [#uses=1]
+ %tmp.i = zext bool %tmp to int ; <int> [#uses=1]
+ ret int %tmp.i
+}
+
+int %main() {
+ %rslt = call int %testByte( sbyte 123)
+ ret int %rslt
+}
diff --git a/test/Transforms/InstCombine/2003-11-03-VarargsCallBug.ll b/test/Transforms/InstCombine/2003-11-03-VarargsCallBug.ll
index 051add8c0b..7e045d8541 100644
--- a/test/Transforms/InstCombine/2003-11-03-VarargsCallBug.ll
+++ b/test/Transforms/InstCombine/2003-11-03-VarargsCallBug.ll
@@ -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
diff --git a/test/Transforms/InstCombine/2006-10-19-SignedToUnsignedCastAndConst-2.ll b/test/Transforms/InstCombine/2006-10-19-SignedToUnsignedCastAndConst-2.ll
index c10e62db8e..f7925e138d 100644
--- a/test/Transforms/InstCombine/2006-10-19-SignedToUnsignedCastAndConst-2.ll
+++ b/test/Transforms/InstCombine/2006-10-19-SignedToUnsignedCastAndConst-2.ll
@@ -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]
diff --git a/test/Transforms/InstCombine/2006-10-19-SignedToUnsignedCastAndConst.ll b/test/Transforms/InstCombine/2006-10-19-SignedToUnsignedCastAndConst.ll
index e35c36694f..f23f5fb229 100644
--- a/test/Transforms/InstCombine/2006-10-19-SignedToUnsignedCastAndConst.ll
+++ b/test/Transforms/InstCombine/2006-10-19-SignedToUnsignedCastAndConst.ll
@@ -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
}
diff --git a/test/Transforms/InstCombine/binop-cast.ll b/test/Transforms/InstCombine/binop-cast.ll
new file mode 100644
index 0000000000..13404df941
--- /dev/null
+++ b/test/Transforms/InstCombine/binop-cast.ll
@@ -0,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
+}
diff --git a/test/Transforms/InstCombine/call-cast-target.ll b/test/Transforms/InstCombine/call-cast-target.ll
index a197742a66..77097caf29 100644
--- a/test/Transforms/InstCombine/call-cast-target.ll
+++ b/test/Transforms/InstCombine/call-cast-target.ll
@@ -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
diff --git a/test/Transforms/InstCombine/cast-malloc.ll b/test/Transforms/InstCombine/cast-malloc.ll
new file mode 100644
index 0000000000..25eb4367c6
--- /dev/null
+++ b/test/Transforms/InstCombine/cast-malloc.ll
@@ -0,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
+}
diff --git a/test/Transforms/InstCombine/cast.ll b/test/Transforms/InstCombine/cast.ll
index ba0b30452c..4accb47af2 100644
--- a/test/Transforms/InstCombine/cast.ll
+++ b/test/Transforms/InstCombine/cast.ll
@@ -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 @@ bool %test16(int* %P) {
ret bool %c
}
-
short %test17(bool %tmp3) {
%c = cast bool %tmp3 to int
%t86 = cast int %c to short
@@ -207,3 +206,8 @@ void %test32(double** %tmp) {
ret void
}
+uint %test33(uint %c1) {
+ %x = bitcast uint %c1 to float
+ %y = bitcast float %x to uint
+ ret uint %y
+}
diff --git a/test/Transforms/InstCombine/cast_ptr.ll b/test/Transforms/InstCombine/cast_ptr.ll
index be0a8970dc..7b572560e4 100644
--- a/test/Transforms/InstCombine/cast_ptr.ll
+++ b/test/Transforms/InstCombine/cast_ptr.ll
@@ -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
diff --git a/test/Transforms/InstCombine/fpcast.ll b/test/Transforms/InstCombine/fpcast.ll
new file mode 100644
index 0000000000..31cd47f619
--- /dev/null
+++ b/test/Transforms/InstCombine/fpcast.ll
@@ -0,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
+}
diff --git a/test/Transforms/InstCombine/getelementptr_cast.ll b/test/Transforms/InstCombine/getelementptr_cast.ll
index ece73f7710..b600874e12 100644
--- a/test/Transforms/InstCombine/getelementptr_cast.ll
+++ b/test/Transforms/InstCombine/getelementptr_cast.ll
@@ -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
}
diff --git a/test/Transforms/InstCombine/getelementptr_index.ll b/test/Transforms/InstCombine/getelementptr_index.ll
index ca7d6e0465..8346fa5191 100644
--- a/test/Transforms/InstCombine/getelementptr_index.ll
+++ b/test/Transforms/InstCombine/getelementptr_index.ll
@@ -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
diff --git a/test/Transforms/InstCombine/narrow.ll b/test/Transforms/InstCombine/narrow.ll
index b8be8c3055..75a78a3f8b 100644
--- a/test/Transforms/InstCombine/narrow.ll
+++ b/test/Transforms/InstCombine/narrow.ll
@@ -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
}
diff --git a/test/Transforms/InstCombine/setcc-cast-cast.ll b/test/Transforms/InstCombine/setcc-cast-cast.ll
new file mode 100644
index 0000000000..e311c523fb
--- /dev/null
+++ b/test/Transforms/InstCombine/setcc-cast-cast.ll
@@ -0,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
+}
diff --git a/test/Transforms/InstCombine/zext.ll b/test/Transforms/InstCombine/zext.ll
new file mode 100644
index 0000000000..27442aab61
--- /dev/null
+++ b/test/Transforms/InstCombine/zext.ll
@@ -0,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
+}
diff --git a/test/Transforms/LevelRaise/2002-03-21-MissedRaise.ll b/test/Transforms/LevelRaise/2002-03-21-MissedRaise.ll
index 61c39723c1..5f6250ef33 100644
--- a/test/Transforms/LevelRaise/2002-03-21-MissedRaise.ll
+++ b/test/Transforms/LevelRaise/2002-03-21-MissedRaise.ll
@@ -1,8 +1,8 @@
-; This example should be raised to return a Hash directly without casting. To
-; successful, all cast instructions should be eliminated from this testcase.
+; This example should be raised to return a Hash directly without casting.
+; LevelRaise should eliminate all cast instructions from this testcase.
;
; XFAIL: *
-; RUN: llvm-as < %s | opt -raise | llvm-dis | not grep cast
+; RUN: llvm-as < %s | opt -raise | llvm-dis | notcast
%Hash = type { { uint, sbyte *, \2 } * *, int (uint) *, int } *
%hash = type { { uint, sbyte *, \2 } * *, int (uint) *, int }
diff --git a/test/Transforms/LevelRaise/2002-03-21-MissedRaise2.ll b/test/Transforms/LevelRaise/2002-03-21-MissedRaise2.ll
index be25022e49..4a778ea0e5 100644
--- a/test/Transforms/LevelRaise/2002-03-21-MissedRaise2.ll
+++ b/test/Transforms/LevelRaise/2002-03-21-MissedRaise2.ll
@@ -3,7 +3,7 @@
; prevented reg115 from being able to change.
;
; XFAIL: *
-; RUN: llvm-as < %s | opt -raise | llvm-dis | grep '= cast' | not grep \*
+; RUN: llvm-as < %s | opt -raise | llvm-dis | not grep bitcast
%Hash = type { { uint, sbyte *, \2 } * *, int (uint) *, int } *
%HashEntry = type { uint, sbyte *, \2 } *
diff --git a/test/Transforms/LevelRaise/2002-03-21-MissedRaise3.ll b/test/Transforms/LevelRaise/2002-03-21-MissedRaise3.ll
index b3e42cc9dc..6379ab5848 100644
--- a/test/Transforms/LevelRaise/2002-03-21-MissedRaise3.ll
+++ b/test/Transforms/LevelRaise/2002-03-21-MissedRaise3.ll
@@ -1,5 +1,5 @@
; XFAIL: *
-; RUN: llvm-as < %s | opt -raise | llvm-dis | grep '= cast' | not grep \*
+; RUN: llvm-as < %s | opt -raise | llvm-dis | not grep bitcast
%Hash = type { { uint, sbyte *, \2 } * *, int (uint) *, int } *
%HashEntry = type { uint, sbyte *, \2 } *
diff --git a/test/Transforms/LevelRaise/2002-04-16-MissedRaise.ll b/test/Transforms/LevelRaise/2002-04-16-MissedRaise.ll
index c1a4e056a9..1fa2fd8253 100644
--- a/test/Transforms/LevelRaise/2002-04-16-MissedRaise.ll
+++ b/test/Transforms/LevelRaise/2002-04-16-MissedRaise.ll
@@ -6,7 +6,7 @@
; return (int*)malloc(i+j);
; }
-; RUN: llvm-as < %s | opt -raise | llvm-dis | grep ' cast ' | not grep '*'
+; RUN: llvm-as < %s | opt -raise | llvm-dis | not grep bitcast
implementation
diff --git a/test/Transforms/LevelRaise/2002-05-02-MissedRaise.ll b/test/Transforms/LevelRaise/2002-05-02-MissedRaise.ll
index 615217e09c..64000918de 100644
--- a/test/Transforms/LevelRaise/2002-05-02-MissedRaise.ll
+++ b/test/Transforms/LevelRaise/2002-05-02-MissedRaise.ll
@@ -1,6 +1,6 @@
; This testcase is not level raised properly...
; XFAIL: *
-; RUN: llvm-as < %s | opt -raise | llvm-dis | grep ' cast ' | not grep '*'
+; RUN: llvm-as < %s | opt -raise | llvm-dis | not grep bitcast
%List = type { int, %List* }
diff --git a/test/Transforms/LevelRaise/2002-05-10-LoadPeephole.ll b/test/Transforms/LevelRaise/2002-05-10-LoadPeephole.ll
index 1e2ca0e0e9..102b57431f 100644
--- a/test/Transforms/LevelRaise/2002-05-10-LoadPeephole.ll
+++ b/test/Transforms/LevelRaise/2002-05-10-LoadPeephole.ll
@@ -1,7 +1,7 @@
; This testcase should have the cast propogated through the load
; just like a store does...
;
-; RUN: llvm-as < %s | opt -raise | llvm-dis | grep ' cast ' | not grep '*'
+; RUN: llvm-as < %s | opt -raise | llvm-dis | not grep 'bitcast uint \*'
int "test"(uint * %Ptr) {
%P2 = cast uint *%Ptr to int *
diff --git a/test/Transforms/LevelRaise/2002-05-23-MissedRaise.ll b/test/Transforms/LevelRaise/2002-05-23-MissedRaise.ll
index c092e6b181..59a4248d5a 100644
--- a/test/Transforms/LevelRaise/2002-05-23-MissedRaise.ll
+++ b/test/Transforms/LevelRaise/2002-05-23-MissedRaise.ll
@@ -1,5 +1,5 @@
; XFAIL: *
-; RUN: llvm-as < %s | opt -raise | llvm-dis | grep '= cast' | not grep \*
+; RUN: llvm-as < %s | opt -raise | llvm-dis | not grep bitcast
%FILE = type { int, ubyte*, ubyte*, ubyte, ubyte, uint, uint, uint }
diff --git a/test/Transforms/LevelRaise/2002-07-16-MissedRaise.ll b/test/Transforms/LevelRaise/2002-07-16-MissedRaise.ll
index c3406bab72..a5ed52ccb5 100644
--- a/test/Transforms/LevelRaise/2002-07-16-MissedRaise.ll
+++ b/test/Transforms/LevelRaise/2002-07-16-MissedRaise.ll
@@ -5,7 +5,7 @@
; This could be fixed by making all stores add themselves to a list, and check
; their arguments are consistent AFTER all other values are propogated.
; XFAIL: *
-; RUN: llvm-as < %s | opt -raise | llvm-dis | not grep '= cast'
+; RUN: llvm-as < %s | opt -raise | llvm-dis | notcast
%Tree = type %struct.tree*
%struct.tree = type { int, double, double, %Tree, %Tree, %Tree, %Tree }
diff --git a/test/Transforms/LevelRaise/2002-07-18-MissedAllocaRaise.ll b/test/Transforms/LevelRaise/2002-07-18-MissedAllocaRaise.ll
index 422b977e24..91301f0510 100644
--- a/test/Transforms/LevelRaise/2002-07-18-MissedAllocaRaise.ll
+++ b/test/Transforms/LevelRaise/2002-07-18-MissedAllocaRaise.ll
@@ -1,6 +1,6 @@
; Looks like we don't raise alloca's like we do mallocs
; XFAIL: *
-; RUN: llvm-as < %s | opt -raise | llvm-dis | grep '= cast' | not grep \*
+; RUN: llvm-as < %s | opt -raise | llvm-dis | not grep bitcast
implementation ; Functions: