aboutsummaryrefslogtreecommitdiffstats
path: root/test/CodeGen/Generic
diff options
context:
space:
mode:
authorVikram S. Adve <vadve@cs.uiuc.edu>2002-07-10 21:54:05 +0000
committerVikram S. Adve <vadve@cs.uiuc.edu>2002-07-10 21:54:05 +0000
commita7a1c7e9719a4358521035be9965603eb1f429a6 (patch)
tree2e633b416dd031f4a24eb869c9eedc39a4f61708 /test/CodeGen/Generic
parent975f6d4f4477a68f9b322843a1bf2ebc24214b3a (diff)
downloadexternal_llvm-a7a1c7e9719a4358521035be9965603eb1f429a6.zip
external_llvm-a7a1c7e9719a4358521035be9965603eb1f429a6.tar.gz
external_llvm-a7a1c7e9719a4358521035be9965603eb1f429a6.tar.bz2
Some of these are feature tests, not regression tests.
This directory needs to be reorganized and some of the tests need changes to make them executable. Also comments would help... git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2865 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/Generic')
-rw-r--r--test/CodeGen/Generic/badlive.ll28
-rw-r--r--test/CodeGen/Generic/constindices.ll44
-rw-r--r--test/CodeGen/Generic/fwdtwice.ll33
-rw-r--r--test/CodeGen/Generic/negintconst.ll48
-rw-r--r--test/CodeGen/Generic/sched.ll30
-rw-r--r--test/CodeGen/Generic/select.ll155
-rw-r--r--test/CodeGen/Generic/spillccr.ll52
7 files changed, 390 insertions, 0 deletions
diff --git a/test/CodeGen/Generic/badlive.ll b/test/CodeGen/Generic/badlive.ll
new file mode 100644
index 0000000..f9c74d2
--- /dev/null
+++ b/test/CodeGen/Generic/badlive.ll
@@ -0,0 +1,28 @@
+implementation
+
+int "main"()
+begin
+bb0:
+ %reg109 = malloc int, uint 100
+ br label %bb2
+
+bb2:
+ %cann-indvar1 = phi int [ 0, %bb0 ], [ %add1-indvar1, %bb2 ]
+ %reg127 = mul int %cann-indvar1, 2
+ %add1-indvar1 = add int %cann-indvar1, 1
+ store int 999, int * %reg109, uint 0
+ %cond1015 = setle int 1, 99
+ %reg128 = add int %reg127, 2
+ br bool %cond1015, label %bb2, label %bb4
+
+bb4: ;[#uses=3]
+ %cann-indvar = phi uint [ %add1-indvar, %bb4 ], [ 0, %bb2 ]
+ %add1-indvar = add uint %cann-indvar, 1 ; <uint> [#uses=1]
+ store int 333, int * %reg109, uint 0
+ %reg131 = add uint %add1-indvar, 3 ; <int> [#uses=1]
+ %cond1017 = setle uint %reg131, 99 ; <bool> [#uses=1]
+ br bool %cond1017, label %bb4, label %bb5
+
+bb5:
+ ret int 0
+end
diff --git a/test/CodeGen/Generic/constindices.ll b/test/CodeGen/Generic/constindices.ll
new file mode 100644
index 0000000..0b8ef91
--- /dev/null
+++ b/test/CodeGen/Generic/constindices.ll
@@ -0,0 +1,44 @@
+; Test that a sequence of constant indices are folded correctly
+; into the equivalent offset at compile-time.
+
+%MixedA = type { float, [15 x int], sbyte, float }
+
+%MixedB = type { float, %MixedA, float }
+
+%fmtArg = internal global [44 x sbyte] c"sqrt(2) = %g\0Aexp(1) = %g\0Api = %g\0Afive = %g\0A\00"; <[44 x sbyte]*> [#uses=1]
+
+implementation
+
+declare int "printf"(sbyte*, ...)
+
+int "main"()
+begin
+ %ScalarA = alloca %MixedA
+ %ScalarB = alloca %MixedB
+ %ArrayA = alloca %MixedA, uint 4
+ %ArrayB = alloca %MixedB, uint 3
+
+ store float 1.4142, %MixedA* %ScalarA, uint 0, ubyte 0
+ store float 2.7183, %MixedB* %ScalarB, uint 0, ubyte 1, ubyte 0
+
+ %fptrA = getelementptr %MixedA* %ArrayA, uint 1, ubyte 0
+ %fptrB = getelementptr %MixedB* %ArrayB, uint 2, ubyte 1, ubyte 0
+
+ store float 3.1415, float* %fptrA
+ store float 5.0, float* %fptrB
+
+ %sqrtTwo = load %MixedA* %ScalarA, uint 0, ubyte 0
+ %exp = load %MixedB* %ScalarB, uint 0, ubyte 1, ubyte 0
+ %pi = load %MixedA* %ArrayA, uint 1, ubyte 0
+ %five = load %MixedB* %ArrayB, uint 2, ubyte 1, ubyte 0
+
+ %dsqrtTwo = cast float %sqrtTwo to double
+ %dexp = cast float %exp to double
+ %dpi = cast float %pi to double
+ %dfive = cast float %five to double
+
+ %castFmt = getelementptr [44 x sbyte]* %fmtArg, uint 0, uint 0
+ call int (sbyte*, ...)* %printf(sbyte* %castFmt, double %dsqrtTwo, double %dexp, double %dpi, double %dfive)
+
+ ret int 0
+end
diff --git a/test/CodeGen/Generic/fwdtwice.ll b/test/CodeGen/Generic/fwdtwice.ll
new file mode 100644
index 0000000..44c7258
--- /dev/null
+++ b/test/CodeGen/Generic/fwdtwice.ll
@@ -0,0 +1,33 @@
+;;
+;; Test the sequence:
+;; cast -> setle 0, %cast -> br %cond
+;; This sequence should cause the cast value to be forwarded twice,
+;; i.e., cast is forwarded to the setle and teh setle is forwarded
+;; to the branch.
+;; register argument of the "branch-on-register" instruction, i.e.,
+;;
+;; This produces the bogus output instruction:
+;; brlez <NULL VALUE>, .L_SumArray_bb3.
+;; This came from %bb1 of sumarrray.ll generated from sumarray.c.
+
+
+;;;; ******************************************************
+implementation
+;;;; ******************************************************
+
+int "SumArray"(int %Num)
+begin
+bb0: ;[#uses=3]
+ br label %Top
+Top:
+ %Num = alloca int ; <int *> [#uses=2]
+ store int %Num, int * %Num
+ %reg108 = load int * %Num ; <int> [#uses=2]
+ %cast1006 = cast int %reg108 to uint ; <uint> [#uses=1]
+ %cond1001 = setle uint %cast1006, 0 ; <bool> [#uses=1]
+ br bool %cond1001, label %bb6, label %Top
+
+bb6:
+ ret int 42
+end
+
diff --git a/test/CodeGen/Generic/negintconst.ll b/test/CodeGen/Generic/negintconst.ll
new file mode 100644
index 0000000..9e671b0
--- /dev/null
+++ b/test/CodeGen/Generic/negintconst.ll
@@ -0,0 +1,48 @@
+; Test that a negative constant smaller than 64 bits (e.g., int)
+; is correctly implemented with sign-extension.
+; In particular, the current code generated is:
+;
+; main:
+; .L_main_LL_0:
+; save %o6, -224, %o6
+; setx .G_fmtArg_1, %o1, %o0
+; setuw 1, %o1 ! i = 1
+; setuw 4294967295, %o3 ! THE BUG: 0x00000000ffffffff
+; setsw 0, %i0
+; add %i6, 1999, %o2 ! fval
+; add %o1, %g0, %o1
+; add %o0, 0, %o0
+; mulx %o1, %o3, %o1 ! ERROR: 0xffffffff; should be -1
+; add %o1, 3, %o1 ! ERROR: 0x100000002; should be 0x2
+; mulx %o1, 12, %o3 !
+; add %o2, %o3, %o3 ! produces bad address!
+; call printf
+; nop
+; jmpl %i7+8, %g0
+; restore %g0, 0, %g0
+;
+; llc produces:
+; ioff = 2 fval = 0xffffffff7fffec90 &fval[2] = 0xb7fffeca8
+; instead of:
+; ioff = 2 fval = 0xffffffff7fffec90 &fval[2] = 0xffffffff7fffeca8
+;
+
+%Results = type { float, float, float }
+
+%fmtArg = internal global [39 x sbyte] c"ioff = %u\09fval = 0x%p\09&fval[2] = 0x%p\0A\00"; <[39 x sbyte]*> [#uses=1]
+
+implementation
+
+declare int "printf"(sbyte*, ...)
+
+int "main"()
+begin
+ %fval = alloca %Results, uint 4
+ %i = add uint 1, 0 ; i = 1
+ %iscale = mul uint %i, 4294967295 ; i*-1 = -1
+ %ioff = add uint %iscale, 3 ; 3+(-i) = 2
+ %fptr = getelementptr %Results* %fval, uint %ioff ; &fval[2]
+ %castFmt = getelementptr [39 x sbyte]* %fmtArg, uint 0, uint 0
+ call int (sbyte*, ...)* %printf(sbyte* %castFmt, uint %ioff, %Results* %fval, %Results* %fptr)
+ ret int 0
+end
diff --git a/test/CodeGen/Generic/sched.ll b/test/CodeGen/Generic/sched.ll
new file mode 100644
index 0000000..b8de02d
--- /dev/null
+++ b/test/CodeGen/Generic/sched.ll
@@ -0,0 +1,30 @@
+implementation
+declare int "printf"(sbyte*, int, float)
+
+
+int "testissue"(int %i, float %x, float %y)
+begin
+bb1:
+ %x1 = mul float %x, %y ;; x1
+ %y1 = mul float %y, 0.75 ;; y1
+ %z1 = add float %x1, %y1 ;; z1 = x1 + y1
+
+ %x2 = mul float %x, 0.5 ;; x2
+ %y2 = mul float %y, 0.9 ;; y2
+ %z2 = add float %x2, %y2 ;; z2 = x2 + y2
+
+ %z3 = add float %z1, %z2 ;; z3 = z1 + z2
+
+ %i1 = shl int %i, ubyte 3 ;; i1
+ %j1 = add int %i, 7 ;; j1
+ %m1 = add int %i1, %j1 ;; k1 = i1 + j1
+;; %m1 = div int %k1, 99 ;; m1 = k1 / 99
+
+ %b = setle int %m1, 6 ;; (m1 <= 6)?
+ br bool %b, label %bb1, label %bb2
+
+bb2:
+ %Msg = cast ulong 0 to sbyte *
+ call int %printf(sbyte* %Msg, int %m1, float %z3)
+ ret int 0
+end
diff --git a/test/CodeGen/Generic/select.ll b/test/CodeGen/Generic/select.ll
new file mode 100644
index 0000000..973bc7e
--- /dev/null
+++ b/test/CodeGen/Generic/select.ll
@@ -0,0 +1,155 @@
+%AConst = constant int 123
+
+implementation
+
+; Test setting values of different constants in registers.
+;
+void "testConsts"(int %N, float %X)
+begin
+; <label>:0
+ %a = add int %N, 1 ; 1 should be put in immed field
+ %a2= add int %N, 12345678 ; constant has to be loaded
+ %b = add short 4, 3 ; one of the operands shd be immed
+ %c = add float %X, 0.0 ; will this be optimzzed?
+ %d = add float %X, 3.1415 ; constant has to be loaded
+ %f = add uint 4294967295, 10 ; result shd be 9 (not in immed fld)
+ %g = add ushort 20, 65535 ; result shd be 19 (65536 in immed fld)
+ %g = add ushort 65535, 30 ; result shd be 29 (not in immed fld)
+ %h = add ubyte 40, 255 ; result shd be 39 (255 in immed fld)
+ %h = add ubyte 255, 50 ; result shd be 49 (not in immed fld)
+
+ ret void
+end
+
+; A SetCC whose result is used should produce instructions to
+; compute the boolean value in a register. One whose result
+; is unused will only generate the condition code but not
+; the boolean result.
+;
+void "unusedBool"(int * %x, int * %y)
+begin
+; <label>:0 ; [#uses=0]
+ seteq int * %x, %y ; <bool>:0 [#uses=1]
+ not bool %0 ; <bool>:1 [#uses=0]
+ setne int * %x, %y ; <bool>:2 [#uses=0]
+ ret void
+end
+
+; A constant argument to a Phi produces a Cast instruction in the
+; corresponding predecessor basic block. This checks a few things:
+; -- phi arguments coming from the bottom of the same basic block
+; (they should not be forward substituted in the machine code!)
+; -- code generation for casts of various types
+; -- use of immediate fields for integral constants of different sizes
+; -- branch on a constant condition
+;
+void "mergeConstants"(int * %x, int * %y)
+begin
+; <label>:0
+ br label %Top
+Top:
+ phi int [ 0, %0 ], [ 1, %Top ], [ 524288, %Next ]
+ phi float [ 0.0, %0 ], [ 1.0, %Top ], [ 2.0, %Next ]
+ phi double [ 0.5, %0 ], [ 1.5, %Top ], [ 2.5, %Next ]
+ phi bool [ true, %0 ], [ false,%Top ], [ true, %Next ]
+ br bool true, label %Top, label %Next
+Next:
+ br label %Top
+end
+
+
+
+; A constant argument to a cast used only once should be forward substituted
+; and loaded where needed, which happens is:
+; -- User of cast has no immediate field
+; -- User of cast has immediate field but constant is too large to fit
+; or constant is not resolved until later (e.g., global address)
+; -- User of cast uses it as a call arg. or return value so it is an implicit
+; use but has to be loaded into a virtual register so that the reg.
+; allocator can allocate the appropriate phys. reg. for it
+;
+int* "castconst"(float)
+begin
+; <label>:0
+ %castbig = cast ulong 99999999 to int
+ %castsmall = cast ulong 1 to int
+ %usebig = add int %castbig, %castsmall
+
+ %castglob = cast int* %AConst to long*
+ %dummyl = load long* %castglob
+
+ %castnull = cast ulong 0 to int*
+ ret int* %castnull
+end
+
+
+
+; Test branch-on-comparison-with-zero, in two ways:
+; 1. can be folded
+; 2. cannot be folded because result of comparison is used twice
+;
+void "testbool"(int, int) ; Def %0, %1
+ const int 0 ; Def 2
+ const int -4 ; Def 3
+begin
+; <label>:0
+ br label %Top
+Top:
+ add int %0, %1 ; Def 4
+ sub int %4, %3 ; Def 5
+ setle int %5, %2 ; Def 0 - bool plane
+ br bool %0, label %retlbl, label %loop
+
+loop:
+ add int %0, %1 ; Def 6
+ sub int %4, %3 ; Def 7
+ setle int %7, %2 ; Def 1 - bool
+ not bool %1 ; Def 2 - bool. first use of bool %1
+ br bool %1, label %loop, label %Top ; second use of bool %1
+
+retlbl:
+ ret void
+end
+
+
+; Test branch on floating point comparison
+;
+void "testfloatbool"(float %x, float %y) ; Def %0, %1 - float
+begin
+; <label>:0
+ br label %Top
+Top:
+ %p = add float %x, %y ; Def 2 - float
+ %z = sub float %x, %y ; Def 3 - float
+ %b = setle float %p, %z ; Def 0 - bool
+ %c = not bool %b ; Def 1 - bool
+ br bool %b, label %Top, label %goon
+goon:
+ ret void
+end
+
+
+; Test cases where an LLVM instruction requires no machine
+; instructions (e.g., cast int* to long). But there are 2 cases:
+; 1. If the result register has only a single use and the use is in the
+; same basic block, the operand will be copy-propagated during
+; instruction selection.
+; 2. If the result register has multiple uses or is in a different
+; basic block, it cannot (or will not) be copy propagated during
+; instruction selection. It will generate a
+; copy instruction (add-with-0), but this copy should get coalesced
+; away by the register allocator.
+;
+int "checkForward"(int %N, int* %A)
+begin
+
+bb2: ;;<label>
+ %reg114 = shl int %N, ubyte 2 ;;
+ %cast115 = cast int %reg114 to int* ;; reg114 will be propagated
+ %reg116 = add int* %A, %cast115 ;;
+ %reg118 = load int* %reg116 ;;
+ %cast117 = cast int %reg118 to long ;; reg118 will be copied 'cos
+ %reg159 = add long 1234567, %cast117 ;; cast117 has 2 uses, here
+ %reg160 = add long 7654321, %cast117 ;; and here.
+ ret void
+end
diff --git a/test/CodeGen/Generic/spillccr.ll b/test/CodeGen/Generic/spillccr.ll
new file mode 100644
index 0000000..d34ea3f
--- /dev/null
+++ b/test/CodeGen/Generic/spillccr.ll
@@ -0,0 +1,52 @@
+; July 6, 2002 -- LLC Regression test
+; This test case checks if the integer CC register %xcc (or %ccr)
+; is correctly spilled. The code fragment came from function
+; MakeGraph in Olden-mst.
+; The original code made all comparisons with 0, so that the %xcc
+; register is not needed for the branch in the first basic block.
+; Replace 0 with 1 in the first comparson so that the
+; branch-on-register instruction cannot be used directly, i.e.,
+; the %xcc register is needed for the first branch.
+;
+ %Graph = type %struct.graph_st*
+ %Hash = type %struct.hash*
+ %HashEntry = type %struct.hash_entry*
+ %Vertex = type %struct.vert_st*
+ %struct.graph_st = type { [1 x %Vertex] }
+ %struct.hash = type { %HashEntry*, int (uint)*, int }
+ %struct.hash_entry = type { uint, sbyte*, %HashEntry }
+ %struct.vert_st = type { int, %Vertex, %Hash }
+%HashRange = internal uninitialized global int ; <int*> [#uses=1]
+%.LC0 = internal global [13 x sbyte] c"Make phase 2\00" ; <[13 x sbyte]*> [#uses=1]
+%.LC1 = internal global [13 x sbyte] c"Make phase 3\00" ; <[13 x sbyte]*> [#uses=1]
+%.LC2 = internal global [13 x sbyte] c"Make phase 4\00" ; <[13 x sbyte]*> [#uses=1]
+%.LC3 = internal global [15 x sbyte] c"Make returning\00" ; <[15 x sbyte]*> [#uses=1]
+
+implementation ; Functions:
+
+%Graph %MakeGraph(int %numvert, int %numproc) {
+bb1: ;[#uses=1]
+ %reg111 = add int %numproc, -1 ; <int> [#uses=3]
+ %cond275 = setlt int %reg111, 1 ; <bool> [#uses=2]
+ %cond276 = setle int %reg111, 0 ; <bool> [#uses=1]
+ %cond277 = setge int %numvert, 0 ; <bool> [#uses=2]
+ %reg162 = add int %numvert, 3 ; <int> [#uses=2]
+ br bool %cond275, label %bb7, label %bb4
+
+bb4:
+ br bool %cond276, label %bb7, label %bb5
+
+bb5:
+ br bool %cond277, label %bb7, label %bb6
+
+bb6: ;[#uses=2]
+ ret %Graph null
+
+bb7: ;[#uses=2]
+ ret %Graph null
+}
+
+int %main(int argc, sbyte** argv) {
+bb1:
+ %reg100 = call %struct.graph_st* (int, int)* %MakeGraph(1, 1)
+