From a7a1c7e9719a4358521035be9965603eb1f429a6 Mon Sep 17 00:00:00 2001 From: "Vikram S. Adve" Date: Wed, 10 Jul 2002 21:54:05 +0000 Subject: [PATCH] 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 --- test/CodeGen/Generic/badlive.ll | 28 +++++ test/CodeGen/Generic/constindices.ll | 44 ++++++++ test/CodeGen/Generic/fwdtwice.ll | 33 ++++++ test/CodeGen/Generic/negintconst.ll | 48 +++++++++ test/CodeGen/Generic/sched.ll | 30 ++++++ test/CodeGen/Generic/select.ll | 155 ++++++++++++++++++++++++++ test/CodeGen/Generic/spillccr.ll | 52 +++++++++ test/LLC/badfuncptr.c | 74 +++++++++++++ test/LLC/badlive.ll | 28 +++++ test/LLC/callargs.c | 156 +++++++++++++++++++++++++++ test/LLC/casts.c | 84 +++++++++++++++ test/LLC/constindices.ll | 44 ++++++++ test/LLC/fwdtwice.ll | 33 ++++++ test/LLC/negintconst.ll | 48 +++++++++ test/LLC/poisson.c | 41 +++++++ test/LLC/sched.ll | 30 ++++++ test/LLC/select.ll | 155 ++++++++++++++++++++++++++ test/LLC/spillccr.ll | 52 +++++++++ test/LLC/testtrace.c | 44 ++++++++ test/LLC/varargs.c | 29 +++++ 20 files changed, 1208 insertions(+) create mode 100644 test/CodeGen/Generic/badlive.ll create mode 100644 test/CodeGen/Generic/constindices.ll create mode 100644 test/CodeGen/Generic/fwdtwice.ll create mode 100644 test/CodeGen/Generic/negintconst.ll create mode 100644 test/CodeGen/Generic/sched.ll create mode 100644 test/CodeGen/Generic/select.ll create mode 100644 test/CodeGen/Generic/spillccr.ll create mode 100644 test/LLC/badfuncptr.c create mode 100644 test/LLC/badlive.ll create mode 100644 test/LLC/callargs.c create mode 100644 test/LLC/casts.c create mode 100644 test/LLC/constindices.ll create mode 100644 test/LLC/fwdtwice.ll create mode 100644 test/LLC/negintconst.ll create mode 100644 test/LLC/poisson.c create mode 100644 test/LLC/sched.ll create mode 100644 test/LLC/select.ll create mode 100644 test/LLC/spillccr.ll create mode 100644 test/LLC/testtrace.c create mode 100644 test/LLC/varargs.c diff --git a/test/CodeGen/Generic/badlive.ll b/test/CodeGen/Generic/badlive.ll new file mode 100644 index 00000000000..f9c74d25dab --- /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 ; [#uses=1] + store int 333, int * %reg109, uint 0 + %reg131 = add uint %add1-indvar, 3 ; [#uses=1] + %cond1017 = setle uint %reg131, 99 ; [#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 00000000000..0b8ef913465 --- /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 00000000000..44c72587b25 --- /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 , .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 ; [#uses=2] + store int %Num, int * %Num + %reg108 = load int * %Num ; [#uses=2] + %cast1006 = cast int %reg108 to uint ; [#uses=1] + %cond1001 = setle uint %cast1006, 0 ; [#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 00000000000..9e671b095b4 --- /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 00000000000..b8de02ddb95 --- /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 00000000000..973bc7e88eb --- /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 +;