diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2006-11-27 01:05:10 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2006-11-27 01:05:10 +0000 |
commit | 3da59db637a887474c1b1346c1f3ccf53b6c4663 (patch) | |
tree | b061e2133efdb9ea9bb334c1b15ceea881bb88f8 /test/Transforms/InstCombine | |
parent | 5fed9b90447a9a95a1f670ccd9c23aea8c937451 (diff) | |
download | external_llvm-3da59db637a887474c1b1346c1f3ccf53b6c4663.zip external_llvm-3da59db637a887474c1b1346c1f3ccf53b6c4663.tar.gz external_llvm-3da59db637a887474c1b1346c1f3ccf53b6c4663.tar.bz2 |
For 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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31931 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstCombine')
-rw-r--r-- | test/Transforms/InstCombine/2003-11-03-VarargsCallBug.ll | 2 | ||||
-rw-r--r-- | test/Transforms/InstCombine/2006-10-19-SignedToUnsignedCastAndConst-2.ll | 2 | ||||
-rw-r--r-- | test/Transforms/InstCombine/2006-10-19-SignedToUnsignedCastAndConst.ll | 9 | ||||
-rw-r--r-- | test/Transforms/InstCombine/binop-cast.ll | 7 | ||||
-rw-r--r-- | test/Transforms/InstCombine/call-cast-target.ll | 2 | ||||
-rw-r--r-- | test/Transforms/InstCombine/cast-malloc.ll | 8 | ||||
-rw-r--r-- | test/Transforms/InstCombine/cast.ll | 8 | ||||
-rw-r--r-- | test/Transforms/InstCombine/cast_ptr.ll | 2 | ||||
-rw-r--r-- | test/Transforms/InstCombine/fpcast.ll | 14 | ||||
-rw-r--r-- | test/Transforms/InstCombine/getelementptr_cast.ll | 6 | ||||
-rw-r--r-- | test/Transforms/InstCombine/getelementptr_index.ll | 2 | ||||
-rw-r--r-- | test/Transforms/InstCombine/narrow.ll | 6 | ||||
-rw-r--r-- | test/Transforms/InstCombine/setcc-cast-cast.ll | 42 | ||||
-rw-r--r-- | test/Transforms/InstCombine/zext.ll | 9 |
14 files changed, 102 insertions, 17 deletions
diff --git a/test/Transforms/InstCombine/2003-11-03-VarargsCallBug.ll b/test/Transforms/InstCombine/2003-11-03-VarargsCallBug.ll index 051add8..7e045d8 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 c10e62d..f7925e1 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 e35c366..f23f5fb 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 0000000..13404df --- /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 a197742..77097ca 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 0000000..25eb436 --- /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 ba0b304..4accb47 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 be0a897..7b57256 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 0000000..31cd47f --- /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 ece73f7..b600874 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 ca7d6e0..8346fa5 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 b8be8c3..75a78a3 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 0000000..e311c52 --- /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 0000000..27442aa --- /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 +} |