It's not necessary to do rounding for alloca operations when the requested
alignment is equal to the stack alignment.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40004 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/CodeGen/Alpha/2005-07-12-TwoMallocCalls.ll b/test/CodeGen/Alpha/2005-07-12-TwoMallocCalls.ll
new file mode 100644
index 0000000..59c6505
--- /dev/null
+++ b/test/CodeGen/Alpha/2005-07-12-TwoMallocCalls.ll
@@ -0,0 +1,19 @@
+; There should be exactly two calls here (memset and malloc), no more.
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha | grep jsr | wc -l | grep 2
+
+%typedef.bc_struct = type opaque
+
+implementation   ; Functions:
+
+declare void %llvm.memset.i64(sbyte*, ubyte, ulong, uint)
+
+bool %l12_l94_bc_divide_endif_2E_3_2E_ce(int* %tmp.71.reload, uint %scale2.1.3, uint %extra.0, %typedef.bc_struct* %n1, %typedef.bc_struct* %n2, int* %tmp.92.reload, uint %tmp.94.reload, int* %tmp.98.reload, uint %tmp.100.reload, sbyte** %tmp.112.out, uint* %tmp.157.out, sbyte** %tmp.158.out) {
+newFuncRoot:
+	%tmp.120 = add uint %extra.0, 2		; <uint> [#uses=1]
+	%tmp.122 = add uint %tmp.120, %tmp.94.reload		; <uint> [#uses=1]
+	%tmp.123 = add uint %tmp.122, %tmp.100.reload		; <uint> [#uses=2]
+	%tmp.112 = malloc sbyte, uint %tmp.123		; <sbyte*> [#uses=3]
+	%tmp.137 = cast uint %tmp.123 to ulong		; <ulong> [#uses=1]
+	tail call void %llvm.memset.i64( sbyte* %tmp.112, ubyte 0, ulong %tmp.137, uint 0 )
+	ret bool true
+}
diff --git a/test/CodeGen/Alpha/2005-12-12-MissingFCMov.ll b/test/CodeGen/Alpha/2005-12-12-MissingFCMov.ll
new file mode 100644
index 0000000..5b9fa19
--- /dev/null
+++ b/test/CodeGen/Alpha/2005-12-12-MissingFCMov.ll
@@ -0,0 +1,44 @@
+; This shouldn't crash
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha
+
+; ModuleID = 'bugpoint-reduced-simplified.bc'
+target endian = little
+target pointersize = 64
+%.str_4 = external global [44 x sbyte]		; <[44 x sbyte]*> [#uses=0]
+
+implementation   ; Functions:
+
+declare void %printf(int, ...)
+
+void %main() {
+entry:
+	%tmp.11861 = setlt long 0, 1		; <bool> [#uses=1]
+	%tmp.19466 = setlt long 0, 1		; <bool> [#uses=1]
+	%tmp.21571 = setlt long 0, 1		; <bool> [#uses=1]
+	%tmp.36796 = setlt long 0, 1		; <bool> [#uses=1]
+	br bool %tmp.11861, label %loopexit.2, label %no_exit.2
+
+no_exit.2:		; preds = %entry
+	ret void
+
+loopexit.2:		; preds = %entry
+	br bool %tmp.19466, label %loopexit.3, label %no_exit.3.preheader
+
+no_exit.3.preheader:		; preds = %loopexit.2
+	ret void
+
+loopexit.3:		; preds = %loopexit.2
+	br bool %tmp.21571, label %no_exit.6, label %no_exit.4
+
+no_exit.4:		; preds = %loopexit.3
+	ret void
+
+no_exit.6:		; preds = %no_exit.6, %loopexit.3
+	%tmp.30793 = setgt long 0, 0		; <bool> [#uses=1]
+	br bool %tmp.30793, label %loopexit.6, label %no_exit.6
+
+loopexit.6:		; preds = %no_exit.6
+	%Z.1 = select bool %tmp.36796, double 1.000000e+00, double 0x3FEFFF7CEDE74EAE		; <double> [#uses=2]
+	tail call void (int, ...)* %printf( int 0, long 0, long 0, long 0, double 1.000000e+00, double 1.000000e+00, double %Z.1, double %Z.1 )
+	ret void
+}
diff --git a/test/CodeGen/Alpha/2006-01-18-MissedGlobal.ll b/test/CodeGen/Alpha/2006-01-18-MissedGlobal.ll
new file mode 100644
index 0000000..f0a5c17
--- /dev/null
+++ b/test/CodeGen/Alpha/2006-01-18-MissedGlobal.ll
@@ -0,0 +1,30 @@
+; The global symbol should be legalized
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha 
+
+target endian = little
+target pointersize = 64
+	%struct.LIST_HELP = type { %struct.LIST_HELP*, sbyte* }
+	%struct._IO_FILE = type { int, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, %struct._IO_marker*, %struct._IO_FILE*, int, int, long, ushort, sbyte, [1 x sbyte], sbyte*, long, sbyte*, sbyte*, int, [44 x sbyte] }
+	%struct._IO_marker = type { %struct._IO_marker*, %struct._IO_FILE*, int }
+%clause_SORT = external global [21 x %struct.LIST_HELP*]		; <[21 x %struct.LIST_HELP*]*> [#uses=1]
+%ia_in = external global %struct._IO_FILE*		; <%struct._IO_FILE**> [#uses=1]
+%multvec_j = external global [100 x uint]		; <[100 x uint]*> [#uses=1]
+
+implementation   ; Functions:
+
+void %main(int %argc) {
+clock_Init.exit:
+	%tmp.5.i575 = load int* null		; <int> [#uses=1]
+	%tmp.309 = seteq int %tmp.5.i575, 0		; <bool> [#uses=1]
+	br bool %tmp.309, label %UnifiedReturnBlock, label %then.17
+
+then.17:		; preds = %clock_Init.exit
+	store %struct._IO_FILE* null, %struct._IO_FILE** %ia_in
+	%savedstack = call sbyte* %llvm.stacksave( )		; <sbyte*> [#uses=0]
+	ret void
+
+UnifiedReturnBlock:		; preds = %clock_Init.exit
+	ret void
+}
+
+declare sbyte* %llvm.stacksave()
diff --git a/test/CodeGen/Alpha/2006-01-26-VaargBreak.ll b/test/CodeGen/Alpha/2006-01-26-VaargBreak.ll
new file mode 100644
index 0000000..e58152e
--- /dev/null
+++ b/test/CodeGen/Alpha/2006-01-26-VaargBreak.ll
@@ -0,0 +1,17 @@
+; This shouldn't crash
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha 
+
+; ModuleID = 'simp.bc'
+target endian = little
+target pointersize = 64
+target triple = "alphaev6-unknown-linux-gnu"
+deplibs = [ "c", "crtend", "stdc++" ]
+	%struct.__va_list_tag = type { sbyte*, int }
+
+implementation   ; Functions:
+
+uint %emit_library_call_value(int %nargs, ...) {
+entry:
+	%tmp.223 = va_arg %struct.__va_list_tag* null, uint		; <uint> [#uses=0]
+	ret uint %tmp.223
+}
diff --git a/test/CodeGen/Alpha/2006-04-04-zextload.ll b/test/CodeGen/Alpha/2006-04-04-zextload.ll
new file mode 100644
index 0000000..75ad7e0
--- /dev/null
+++ b/test/CodeGen/Alpha/2006-04-04-zextload.ll
@@ -0,0 +1,36 @@
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha
+
+target endian = little
+target pointersize = 64
+target triple = "alphaev67-unknown-linux-gnu"
+	%llvm.dbg.compile_unit.type = type { uint, {  }*, uint, uint, sbyte*, sbyte*, sbyte* }
+	%struct._Callback_list = type { %struct._Callback_list*, void (uint, %struct.ios_base*, int)*, int, int }
+	%struct._Impl = type { int, %struct.facet**, ulong, %struct.facet**, sbyte** }
+	%struct._Words = type { sbyte*, long }
+	"struct.__codecvt_abstract_base<char,char,__mbstate_t>" = type { %struct.facet }
+	"struct.basic_streambuf<char,std::char_traits<char> >" = type { int (...)**, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, %struct.locale }
+	%struct.facet = type { int (...)**, int }
+	%struct.ios_base = type { int (...)**, long, long, uint, uint, uint, %struct._Callback_list*, %struct._Words, [8 x %struct._Words], int, %struct._Words*, %struct.locale }
+	%struct.locale = type { %struct._Impl* }
+	"struct.ostreambuf_iterator<char,std::char_traits<char> >" = type { "struct.basic_streambuf<char,std::char_traits<char> >"*, bool }
+%llvm.dbg.compile_unit1047 = external global %llvm.dbg.compile_unit.type		; <%llvm.dbg.compile_unit.type*> [#uses=1]
+
+implementation   ; Functions:
+
+void %_ZNKSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE15_M_insert_floatIdEES3_S3_RSt8ios_baseccT_() {
+entry:
+	%tmp234 = seteq sbyte 0, 0		; <bool> [#uses=1]
+	br bool %tmp234, label %cond_next243, label %cond_true235
+
+cond_true235:		; preds = %entry
+	ret void
+
+cond_next243:		; preds = %entry
+	%tmp428 = load long* null		; <long> [#uses=1]
+	%tmp428 = cast long %tmp428 to uint		; <uint> [#uses=1]
+	%tmp429 = alloca sbyte, uint %tmp428		; <sbyte*> [#uses=0]
+	call void %llvm.dbg.stoppoint( uint 1146, uint 0, {  }* cast (%llvm.dbg.compile_unit.type* %llvm.dbg.compile_unit1047 to {  }*) )
+	unreachable
+}
+
+declare void %llvm.dbg.stoppoint(uint, uint, {  }*)
diff --git a/test/CodeGen/Alpha/2006-07-03-ASMFormalLowering.ll b/test/CodeGen/Alpha/2006-07-03-ASMFormalLowering.ll
new file mode 100644
index 0000000..0f2da53
--- /dev/null
+++ b/test/CodeGen/Alpha/2006-07-03-ASMFormalLowering.ll
@@ -0,0 +1,20 @@
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha
+
+target endian = little
+target pointersize = 64
+target triple = "alphaev67-unknown-linux-gnu"
+
+implementation   ; Functions:
+
+int %_ZN9__gnu_cxx18__exchange_and_addEPVii(int* %__mem, int %__val) {
+entry:
+        %__tmp = alloca int, align 4            ; <int*> [#uses=1]
+        %tmp3 = call int asm sideeffect "\0A$$Lxadd_0:\0A\09ldl_l  $0,$3\0A\09addl   $0,$4,$1\0A\09stl_c  $1,$2\0A\09beq    $1,$$Lxadd_0\0A\09mb", "=&r,=*&r,=*m,m,r"( int* %__tmp, int* %__mem, int* %__mem, int %__val )          ; <int> [#uses=1]
+        ret int %tmp3
+}
+
+void %_ZN9__gnu_cxx12__atomic_addEPVii(int* %__mem, int %__val) {
+entry:
+        %tmp2 = call int asm sideeffect "\0A$$Ladd_1:\0A\09ldl_l  $0,$2\0A\09addl   $0,$3,$0\0A\09stl_c  $0,$1\0A\09beq    $0,$$Ladd_1\0A\09mb", "=&r,=*m,m,r"( int* %__mem, int* %__mem, int %__val )              ; <int> [#uses=0]
+        ret void
+}
diff --git a/test/CodeGen/Alpha/2006-11-01-vastart.ll b/test/CodeGen/Alpha/2006-11-01-vastart.ll
new file mode 100644
index 0000000..61d6db9
--- /dev/null
+++ b/test/CodeGen/Alpha/2006-11-01-vastart.ll
@@ -0,0 +1,18 @@
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha
+
+target datalayout = "e-p:64:64"
+target endian = little
+target pointersize = 64
+target triple = "alphaev67-unknown-linux-gnu"
+        %struct.va_list = type { sbyte*, int, int }
+
+implementation   ; Functions:
+
+void %yyerror(int, ...) {
+entry:
+        call void %llvm.va_start( %struct.va_list* null )
+        ret void
+}
+
+declare void %llvm.va_start(%struct.va_list*)
+
diff --git a/test/CodeGen/Alpha/add.ll b/test/CodeGen/Alpha/add.ll
new file mode 100644
index 0000000..16ce2b0
--- /dev/null
+++ b/test/CodeGen/Alpha/add.ll
@@ -0,0 +1,179 @@
+;test all the shifted and signextending adds and subs with and without consts
+;
+; RUN: llvm-as < %s | llc -march=alpha -o %t.s -f
+; RUN: grep {	addl} %t.s | wc -l | grep 2
+; RUN: grep {	addq} %t.s | wc -l | grep 2
+; RUN: grep {	subl} %t.s | wc -l | grep 2
+; RUN: grep {	subq} %t.s | wc -l | grep 1
+;
+; RUN: grep {lda \$0,-100(\$16)} %t.s | wc -l | grep 1
+; RUN: grep {s4addl} %t.s | wc -l | grep 2
+; RUN: grep {s8addl} %t.s | wc -l | grep 2
+; RUN: grep {s4addq} %t.s | wc -l | grep 2
+; RUN: grep {s8addq} %t.s | wc -l | grep 2
+;
+; RUN: grep {s4subl} %t.s | wc -l | grep 2
+; RUN: grep {s8subl} %t.s | wc -l | grep 2
+; RUN: grep {s4subq} %t.s | wc -l | grep 2
+; RUN: grep {s8subq} %t.s | wc -l | grep 2
+
+
+define i32 @al(i32 sext %x.s, i32 sext %y.s) sext {
+entry:
+	%tmp.3.s = add i32 %y.s, %x.s		; <i32> [#uses=1]
+	ret i32 %tmp.3.s
+}
+
+define i32 @ali(i32 sext %x.s) sext {
+entry:
+	%tmp.3.s = add i32 100, %x.s		; <i32> [#uses=1]
+	ret i32 %tmp.3.s
+}
+
+define i64 @aq(i64 sext %x.s, i64 sext %y.s) sext {
+entry:
+	%tmp.3.s = add i64 %y.s, %x.s		; <i64> [#uses=1]
+	ret i64 %tmp.3.s
+}
+
+define i64 @aqi(i64 %x.s) {
+entry:
+	%tmp.3.s = add i64 100, %x.s		; <i64> [#uses=1]
+	ret i64 %tmp.3.s
+}
+
+define i32 @sl(i32 sext %x.s, i32 sext %y.s) sext {
+entry:
+	%tmp.3.s = sub i32 %y.s, %x.s		; <i32> [#uses=1]
+	ret i32 %tmp.3.s
+}
+
+define i32 @sli(i32 sext %x.s) sext {
+entry:
+	%tmp.3.s = sub i32 %x.s, 100		; <i32> [#uses=1]
+	ret i32 %tmp.3.s
+}
+
+define i64 @sq(i64 %x.s, i64 %y.s) {
+entry:
+	%tmp.3.s = sub i64 %y.s, %x.s		; <i64> [#uses=1]
+	ret i64 %tmp.3.s
+}
+
+define i64 @sqi(i64 %x.s) {
+entry:
+	%tmp.3.s = sub i64 %x.s, 100		; <i64> [#uses=1]
+	ret i64 %tmp.3.s
+}
+
+define i32 @a4l(i32 sext %x.s, i32 sext %y.s) sext {
+entry:
+	%tmp.1.s = shl i32 %y.s, 2		; <i32> [#uses=1]
+	%tmp.3.s = add i32 %tmp.1.s, %x.s		; <i32> [#uses=1]
+	ret i32 %tmp.3.s
+}
+
+define i32 @a8l(i32 sext %x.s, i32 sext %y.s) sext {
+entry:
+	%tmp.1.s = shl i32 %y.s, 3		; <i32> [#uses=1]
+	%tmp.3.s = add i32 %tmp.1.s, %x.s		; <i32> [#uses=1]
+	ret i32 %tmp.3.s
+}
+
+define i64 @a4q(i64 %x.s, i64 %y.s) {
+entry:
+	%tmp.1.s = shl i64 %y.s, 2		; <i64> [#uses=1]
+	%tmp.3.s = add i64 %tmp.1.s, %x.s		; <i64> [#uses=1]
+	ret i64 %tmp.3.s
+}
+
+define i64 @a8q(i64 %x.s, i64 %y.s) {
+entry:
+	%tmp.1.s = shl i64 %y.s, 3		; <i64> [#uses=1]
+	%tmp.3.s = add i64 %tmp.1.s, %x.s		; <i64> [#uses=1]
+	ret i64 %tmp.3.s
+}
+
+define i32 @a4li(i32 sext %y.s) sext {
+entry:
+	%tmp.1.s = shl i32 %y.s, 2		; <i32> [#uses=1]
+	%tmp.3.s = add i32 100, %tmp.1.s		; <i32> [#uses=1]
+	ret i32 %tmp.3.s
+}
+
+define i32 @a8li(i32 sext %y.s) sext {
+entry:
+	%tmp.1.s = shl i32 %y.s, 3		; <i32> [#uses=1]
+	%tmp.3.s = add i32 100, %tmp.1.s		; <i32> [#uses=1]
+	ret i32 %tmp.3.s
+}
+
+define i64 @a4qi(i64 %y.s) {
+entry:
+	%tmp.1.s = shl i64 %y.s, 2		; <i64> [#uses=1]
+	%tmp.3.s = add i64 100, %tmp.1.s		; <i64> [#uses=1]
+	ret i64 %tmp.3.s
+}
+
+define i64 @a8qi(i64 %y.s) {
+entry:
+	%tmp.1.s = shl i64 %y.s, 3		; <i64> [#uses=1]
+	%tmp.3.s = add i64 100, %tmp.1.s		; <i64> [#uses=1]
+	ret i64 %tmp.3.s
+}
+
+define i32 @s4l(i32 sext %x.s, i32 sext %y.s) sext {
+entry:
+	%tmp.1.s = shl i32 %y.s, 2		; <i32> [#uses=1]
+	%tmp.3.s = sub i32 %tmp.1.s, %x.s		; <i32> [#uses=1]
+	ret i32 %tmp.3.s
+}
+
+define i32 @s8l(i32 sext %x.s, i32 sext %y.s) sext {
+entry:
+	%tmp.1.s = shl i32 %y.s, 3		; <i32> [#uses=1]
+	%tmp.3.s = sub i32 %tmp.1.s, %x.s		; <i32> [#uses=1]
+	ret i32 %tmp.3.s
+}
+
+define i64 @s4q(i64 %x.s, i64 %y.s) {
+entry:
+	%tmp.1.s = shl i64 %y.s, 2		; <i64> [#uses=1]
+	%tmp.3.s = sub i64 %tmp.1.s, %x.s		; <i64> [#uses=1]
+	ret i64 %tmp.3.s
+}
+
+define i64 @s8q(i64 %x.s, i64 %y.s) {
+entry:
+	%tmp.1.s = shl i64 %y.s, 3		; <i64> [#uses=1]
+	%tmp.3.s = sub i64 %tmp.1.s, %x.s		; <i64> [#uses=1]
+	ret i64 %tmp.3.s
+}
+
+define i32 @s4li(i32 sext %y.s) sext {
+entry:
+	%tmp.1.s = shl i32 %y.s, 2		; <i32> [#uses=1]
+	%tmp.3.s = sub i32 %tmp.1.s, 100		; <i32> [#uses=1]
+	ret i32 %tmp.3.s
+}
+
+define i32 @s8li(i32 sext %y.s) sext {
+entry:
+	%tmp.1.s = shl i32 %y.s, 3		; <i32> [#uses=1]
+	%tmp.3.s = sub i32 %tmp.1.s, 100		; <i32> [#uses=1]
+	ret i32 %tmp.3.s
+}
+
+define i64 @s4qi(i64 %y.s) {
+entry:
+	%tmp.1.s = shl i64 %y.s, 2		; <i64> [#uses=1]
+	%tmp.3.s = sub i64 %tmp.1.s, 100		; <i64> [#uses=1]
+	ret i64 %tmp.3.s
+}
+
+define i64 @s8qi(i64 %y.s) {
+entry:
+	%tmp.1.s = shl i64 %y.s, 3		; <i64> [#uses=1]
+	%tmp.3.s = sub i64 %tmp.1.s, 100		; <i64> [#uses=1]
+	ret i64 %tmp.3.s
+}
diff --git a/test/CodeGen/Alpha/bic.ll b/test/CodeGen/Alpha/bic.ll
new file mode 100644
index 0000000..4e55d18
--- /dev/null
+++ b/test/CodeGen/Alpha/bic.ll
@@ -0,0 +1,11 @@
+; Make sure this testcase codegens to the bic instruction
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha | grep {bic}
+
+implementation   ; Functions:
+
+long %bar(long %x, long %y) {
+entry:
+	%tmp.1 = xor long %x, -1  		; <long> [#uses=1]
+        %tmp.2 = and long %y, %tmp.1
+	ret long %tmp.2
+}
diff --git a/test/CodeGen/Alpha/bsr.ll b/test/CodeGen/Alpha/bsr.ll
new file mode 100644
index 0000000..32ea0cb
--- /dev/null
+++ b/test/CodeGen/Alpha/bsr.ll
@@ -0,0 +1,13 @@
+; Make sure this testcase codegens the bsr instruction
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha | grep bsr
+
+implementation
+
+internal long %abc(int %x) {
+	%tmp.2 = add int %x, -1		; <int> [#uses=1]
+	%tmp.0 = call long %abc( int %tmp.2 )		; <long> [#uses=1]
+	%tmp.5 = add int %x, -2		; <int> [#uses=1]
+	%tmp.3 = call long %abc( int %tmp.5 )		; <long> [#uses=1]
+	%tmp.6 = add long %tmp.0, %tmp.3		; <long> [#uses=1]
+	ret long %tmp.6
+}
diff --git a/test/CodeGen/Alpha/call_adj.ll b/test/CodeGen/Alpha/call_adj.ll
new file mode 100644
index 0000000..da47c6c
--- /dev/null
+++ b/test/CodeGen/Alpha/call_adj.ll
@@ -0,0 +1,15 @@
+;All this should do is not crash
+;RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha
+
+target endian = little
+target pointersize = 64
+target triple = "alphaev67-unknown-linux-gnu"
+
+implementation   ; Functions:
+
+void %_ZNSt13basic_filebufIcSt11char_traitsIcEE22_M_convert_to_externalEPcl(uint %f) {
+entry:
+	%tmp49 = alloca sbyte, uint %f		; <sbyte*> [#uses=1]
+	%tmp = call uint null( sbyte* null, sbyte* null, sbyte* null, sbyte* null, sbyte* null, sbyte* null, sbyte* null)
+	ret void
+}
diff --git a/test/CodeGen/Alpha/cmov.ll b/test/CodeGen/Alpha/cmov.ll
new file mode 100644
index 0000000..33f1eb8
--- /dev/null
+++ b/test/CodeGen/Alpha/cmov.ll
@@ -0,0 +1,24 @@
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha | not grep cmovlt
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha | grep cmoveq
+
+
+long %cmov_lt(long %a, long %c) {
+entry:
+	%tmp.1 = setlt long %c, 0
+	%retval = select bool %tmp.1, long %a, long 10
+	ret long %retval
+}
+
+long %cmov_const(long %a, long %b, long %c) {
+entry:
+        %tmp.1 = setlt long %a, %b
+        %retval = select bool %tmp.1, long %c, long 10
+        ret long %retval
+}
+
+long %cmov_lt2(long %a, long %c) {
+entry:
+	%tmp.1 = setgt long %c, 0
+	%retval = select bool %tmp.1, long 10, long %a
+	ret long %retval
+}
diff --git a/test/CodeGen/Alpha/cmpbge.ll b/test/CodeGen/Alpha/cmpbge.ll
new file mode 100644
index 0000000..b7b1c09
--- /dev/null
+++ b/test/CodeGen/Alpha/cmpbge.ll
@@ -0,0 +1,16 @@
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha | grep cmpbge | wc -l | grep 2
+
+bool %test1(ulong %A, ulong %B) {
+	%C = and ulong %A, 255
+	%D = and ulong %B, 255
+	%E = setge ulong %C, %D
+	ret bool %E
+}
+
+bool %test2(ulong %a, ulong %B) {
+	%A = shl ulong %a, ubyte 1
+	%C = and ulong %A, 254
+	%D = and ulong %B, 255
+	%E = setge ulong %C, %D
+	ret bool %E
+}
diff --git a/test/CodeGen/Alpha/ctlz.ll b/test/CodeGen/Alpha/ctlz.ll
new file mode 100644
index 0000000..0ad014d
--- /dev/null
+++ b/test/CodeGen/Alpha/ctlz.ll
@@ -0,0 +1,14 @@
+; Make sure this testcase codegens to the ctlz instruction
+; RUN: llvm-as < %s | llc -march=alpha -mcpu=ev67 | grep -i ctlz
+; RUN: llvm-as < %s | llc -march=alpha -mattr=+CIX | grep -i ctlz
+; RUN: llvm-as < %s | llc -march=alpha -mcpu=ev6 | not grep -i ctlz
+; RUN: llvm-as < %s | llc -march=alpha -mcpu=ev56 | not grep -i ctlz
+; RUN: llvm-as < %s | llc -march=alpha -mattr=-CIX | not grep -i ctlz
+
+declare i32 @llvm.ctlz.i8(i8)
+
+define i32 @bar(i8 %x) {
+entry:
+	%tmp.1 = call i32 @llvm.ctlz.i8( i8 %x ) 
+	ret i32 %tmp.1
+}
diff --git a/test/CodeGen/Alpha/ctlz_e.ll b/test/CodeGen/Alpha/ctlz_e.ll
new file mode 100644
index 0000000..9d7c44c
--- /dev/null
+++ b/test/CodeGen/Alpha/ctlz_e.ll
@@ -0,0 +1,12 @@
+; Make sure this testcase does not use ctpop
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha | not grep -i ctpop 
+
+declare ulong %llvm.ctlz.i64(ulong)
+
+implementation   ; Functions:
+
+ulong %bar(ulong %x) {
+entry:
+	%tmp.1 = call ulong %llvm.ctlz.i64( ulong %x ) 
+	ret ulong %tmp.1
+}
diff --git a/test/CodeGen/Alpha/ctpop.ll b/test/CodeGen/Alpha/ctpop.ll
new file mode 100644
index 0000000..388c121
--- /dev/null
+++ b/test/CodeGen/Alpha/ctpop.ll
@@ -0,0 +1,20 @@
+; Make sure this testcase codegens to the ctpop instruction
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha -mcpu=ev67 | grep -i ctpop
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha -mattr=+CIX | \
+; RUN:   grep -i ctpop
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha -mcpu=ev6 | \
+; RUN:   not grep -i ctpop
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha -mcpu=ev56 | \
+; RUN:   not grep -i ctpop
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha -mattr=-CIX | \
+; RUN:   not grep -i ctpop
+
+declare long %llvm.ctpop.i64(long)
+
+implementation   ; Functions:
+
+long %bar(long %x) {
+entry:
+	%tmp.1 = call long %llvm.ctpop.i64( long %x ) 
+	ret long %tmp.1
+}
diff --git a/test/CodeGen/Alpha/dg.exp b/test/CodeGen/Alpha/dg.exp
new file mode 100644
index 0000000..fb9f710
--- /dev/null
+++ b/test/CodeGen/Alpha/dg.exp
@@ -0,0 +1,5 @@
+load_lib llvm.exp
+
+if { [llvm_supports_target Alpha] } {
+  RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll}]]
+}
diff --git a/test/CodeGen/Alpha/eqv.ll b/test/CodeGen/Alpha/eqv.ll
new file mode 100644
index 0000000..76bbc92
--- /dev/null
+++ b/test/CodeGen/Alpha/eqv.ll
@@ -0,0 +1,11 @@
+; Make sure this testcase codegens to the eqv instruction
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha | grep eqv
+
+implementation   ; Functions:
+
+long %bar(long %x, long %y) {
+entry:
+	%tmp.1 = xor long %x, -1  		; <long> [#uses=1]
+        %tmp.2 = xor long %y, %tmp.1
+	ret long %tmp.2
+}
diff --git a/test/CodeGen/Alpha/i32_sub_1.ll b/test/CodeGen/Alpha/i32_sub_1.ll
new file mode 100644
index 0000000..ae254f2
--- /dev/null
+++ b/test/CodeGen/Alpha/i32_sub_1.ll
@@ -0,0 +1,9 @@
+; Make sure this testcase codegens to the ctpop instruction
+; RUN: llvm-as < %s | llc -march=alpha | grep -i {subl \$16,1,\$0}
+
+
+define i32 @foo(i32 sext %x) sext {
+entry:
+	%tmp.1 = add i32 %x, -1		; <int> [#uses=1]
+	ret i32 %tmp.1
+}
diff --git a/test/CodeGen/Alpha/jmp_table.ll b/test/CodeGen/Alpha/jmp_table.ll
new file mode 100644
index 0000000..175e7bf
--- /dev/null
+++ b/test/CodeGen/Alpha/jmp_table.ll
@@ -0,0 +1,101 @@
+; try to check that we have the most important instructions, which shouldn't 
+; appear otherwise
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha | grep jmp
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha | grep gprel32
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha | grep ldl
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha | grep rodata
+; END.
+
+target endian = little
+target pointersize = 64
+target triple = "alphaev67-unknown-linux-gnu"
+%str = internal constant [2 x sbyte] c"1\00"		; <[2 x sbyte]*> [#uses=1]
+%str1 = internal constant [2 x sbyte] c"2\00"		; <[2 x sbyte]*> [#uses=1]
+%str2 = internal constant [2 x sbyte] c"3\00"		; <[2 x sbyte]*> [#uses=1]
+%str3 = internal constant [2 x sbyte] c"4\00"		; <[2 x sbyte]*> [#uses=1]
+%str4 = internal constant [2 x sbyte] c"5\00"		; <[2 x sbyte]*> [#uses=1]
+%str5 = internal constant [2 x sbyte] c"6\00"		; <[2 x sbyte]*> [#uses=1]
+%str6 = internal constant [2 x sbyte] c"7\00"		; <[2 x sbyte]*> [#uses=1]
+%str7 = internal constant [2 x sbyte] c"8\00"		; <[2 x sbyte]*> [#uses=1]
+
+implementation   ; Functions:
+
+int %main(int %x, sbyte** %y) {
+entry:
+	%x_addr = alloca int		; <int*> [#uses=2]
+	%y_addr = alloca sbyte**		; <sbyte***> [#uses=1]
+	%retval = alloca int, align 4		; <int*> [#uses=2]
+	%tmp = alloca int, align 4		; <int*> [#uses=2]
+	%foo = alloca sbyte*, align 8		; <sbyte**> [#uses=9]
+	"alloca point" = cast int 0 to int		; <int> [#uses=0]
+	store int %x, int* %x_addr
+	store sbyte** %y, sbyte*** %y_addr
+	%tmp = load int* %x_addr		; <int> [#uses=1]
+	switch int %tmp, label %bb15 [
+		 int 1, label %bb
+		 int 2, label %bb1
+		 int 3, label %bb3
+		 int 4, label %bb5
+		 int 5, label %bb7
+		 int 6, label %bb9
+		 int 7, label %bb11
+		 int 8, label %bb13
+	]
+
+bb:		; preds = %entry
+	%tmp = getelementptr [2 x sbyte]* %str, int 0, ulong 0		; <sbyte*> [#uses=1]
+	store sbyte* %tmp, sbyte** %foo
+	br label %bb16
+
+bb1:		; preds = %entry
+	%tmp2 = getelementptr [2 x sbyte]* %str1, int 0, ulong 0		; <sbyte*> [#uses=1]
+	store sbyte* %tmp2, sbyte** %foo
+	br label %bb16
+
+bb3:		; preds = %entry
+	%tmp4 = getelementptr [2 x sbyte]* %str2, int 0, ulong 0		; <sbyte*> [#uses=1]
+	store sbyte* %tmp4, sbyte** %foo
+	br label %bb16
+
+bb5:		; preds = %entry
+	%tmp6 = getelementptr [2 x sbyte]* %str3, int 0, ulong 0		; <sbyte*> [#uses=1]
+	store sbyte* %tmp6, sbyte** %foo
+	br label %bb16
+
+bb7:		; preds = %entry
+	%tmp8 = getelementptr [2 x sbyte]* %str4, int 0, ulong 0		; <sbyte*> [#uses=1]
+	store sbyte* %tmp8, sbyte** %foo
+	br label %bb16
+
+bb9:		; preds = %entry
+	%tmp10 = getelementptr [2 x sbyte]* %str5, int 0, ulong 0		; <sbyte*> [#uses=1]
+	store sbyte* %tmp10, sbyte** %foo
+	br label %bb16
+
+bb11:		; preds = %entry
+	%tmp12 = getelementptr [2 x sbyte]* %str6, int 0, ulong 0		; <sbyte*> [#uses=1]
+	store sbyte* %tmp12, sbyte** %foo
+	br label %bb16
+
+bb13:		; preds = %entry
+	%tmp14 = getelementptr [2 x sbyte]* %str7, int 0, ulong 0		; <sbyte*> [#uses=1]
+	store sbyte* %tmp14, sbyte** %foo
+	br label %bb16
+
+bb15:		; preds = %entry
+	br label %bb16
+
+bb16:		; preds = %bb15, %bb13, %bb11, %bb9, %bb7, %bb5, %bb3, %bb1, %bb
+	%tmp17 = load sbyte** %foo		; <sbyte*> [#uses=1]
+	%tmp18 = call int (...)* %print( sbyte* %tmp17 )		; <int> [#uses=0]
+	store int 0, int* %tmp
+	%tmp19 = load int* %tmp		; <int> [#uses=1]
+	store int %tmp19, int* %retval
+	br label %return
+
+return:		; preds = %bb16
+	%retval = load int* %retval		; <int> [#uses=1]
+	ret int %retval
+}
+
+declare int %print(...)
diff --git a/test/CodeGen/Alpha/mul5.ll b/test/CodeGen/Alpha/mul5.ll
new file mode 100644
index 0000000..8159ff0
--- /dev/null
+++ b/test/CodeGen/Alpha/mul5.ll
@@ -0,0 +1,51 @@
+; Make sure this testcase does not use mulq
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha | \
+; RUN:   not grep -i mul
+
+implementation   ; Functions:
+
+ulong %foo1(ulong %x) {
+entry:
+	%tmp.1 = mul ulong %x, 9		; <ulong> [#uses=1]
+	ret ulong %tmp.1
+}
+ulong %foo3(ulong %x) {
+entry:
+        %tmp.1 = mul ulong %x, 259
+	ret ulong %tmp.1
+}
+
+ulong %foo4l(ulong %x) {
+entry:
+        %tmp.1 = mul ulong %x, 260
+	ret ulong %tmp.1
+}
+
+ulong %foo4ln(ulong %x) {
+entry:
+        %tmp.1 = mul ulong %x, 508
+	ret ulong %tmp.1
+}
+ulong %foo4ln_more(ulong %x) {
+entry:
+        %tmp.1 = mul ulong %x, 252
+	ret ulong %tmp.1
+}
+
+ulong %foo1n(ulong %x) {
+entry:
+        %tmp.1 = mul ulong %x, 511
+	ret ulong %tmp.1
+}
+
+ulong %foo8l(ulong %x) {
+entry:
+        %tmp.1 = mul ulong %x, 768
+        ret ulong %tmp.1
+}
+
+long %bar(long %x) {
+entry:
+	%tmp.1 = mul long %x, 5		; <long> [#uses=1]
+	ret long %tmp.1
+}
diff --git a/test/CodeGen/Alpha/neg1.ll b/test/CodeGen/Alpha/neg1.ll
new file mode 100644
index 0000000..037e3a2
--- /dev/null
+++ b/test/CodeGen/Alpha/neg1.ll
@@ -0,0 +1,9 @@
+; Make sure this testcase codegens to the lda -1 instruction
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha | grep {\\-1}
+
+implementation   ; Functions:
+
+long %bar() {
+entry:
+	ret long -1
+}
diff --git a/test/CodeGen/Alpha/not.ll b/test/CodeGen/Alpha/not.ll
new file mode 100644
index 0000000..3423aa7
--- /dev/null
+++ b/test/CodeGen/Alpha/not.ll
@@ -0,0 +1,10 @@
+; Make sure this testcase codegens to the ornot instruction
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha | grep eqv
+
+implementation   ; Functions:
+
+long %bar(long %x) {
+entry:
+	%tmp.1 = xor long %x, -1  		; <long> [#uses=1]
+	ret long %tmp.1
+}
diff --git a/test/CodeGen/Alpha/ornot.ll b/test/CodeGen/Alpha/ornot.ll
new file mode 100644
index 0000000..d2da888
--- /dev/null
+++ b/test/CodeGen/Alpha/ornot.ll
@@ -0,0 +1,11 @@
+; Make sure this testcase codegens to the ornot instruction
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha | grep ornot
+
+implementation   ; Functions:
+
+long %bar(long %x, long %y) {
+entry:
+	%tmp.1 = xor long %x, -1  		; <long> [#uses=1]
+        %tmp.2 = or long %y, %tmp.1
+	ret long %tmp.2
+}
diff --git a/test/CodeGen/Alpha/rpcc.ll b/test/CodeGen/Alpha/rpcc.ll
new file mode 100644
index 0000000..ba143a6
--- /dev/null
+++ b/test/CodeGen/Alpha/rpcc.ll
@@ -0,0 +1,10 @@
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha | grep rpcc
+
+declare ulong %llvm.readcyclecounter()
+
+ulong %foo() {
+entry:
+%tmp.1 = call ulong %llvm.readcyclecounter ()
+ret ulong %tmp.1
+}
+
diff --git a/test/CodeGen/Alpha/srl_and.ll b/test/CodeGen/Alpha/srl_and.ll
new file mode 100644
index 0000000..2ed1bf9
--- /dev/null
+++ b/test/CodeGen/Alpha/srl_and.ll
@@ -0,0 +1,10 @@
+; Make sure this testcase codegens to the zapnot instruction
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha | grep zapnot
+
+ulong %foo(ulong %y) {
+entry:
+        %tmp = shr ulong %y, ubyte 3            ; <ulong> [#uses=1]
+        %tmp2 = and ulong %tmp, 8191            ; <ulong> [#uses=1]
+        ret ulong %tmp2
+}
+
diff --git a/test/CodeGen/Alpha/weak.ll b/test/CodeGen/Alpha/weak.ll
new file mode 100644
index 0000000..aefaefd
--- /dev/null
+++ b/test/CodeGen/Alpha/weak.ll
@@ -0,0 +1,17 @@
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha | grep .weak.*f
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha | grep .weak.*h
+
+implementation   ; Functions:
+
+weak uint %f() {
+entry:
+	unreachable
+}
+
+void %g() {
+entry:
+        tail call void %h( )
+        ret void
+}
+
+declare extern_weak void %h()
diff --git a/test/CodeGen/Alpha/zapnot.ll b/test/CodeGen/Alpha/zapnot.ll
new file mode 100644
index 0000000..05e90ec
--- /dev/null
+++ b/test/CodeGen/Alpha/zapnot.ll
@@ -0,0 +1,9 @@
+; Make sure this testcase codegens to the bic instruction
+; RUN: llvm-as < %s | llc -march=alpha | grep zapnot
+
+
+define i16 @foo(i64 %y) zext {
+entry:
+        %tmp.1 = trunc i64 %y to i16         ; <ushort> [#uses=1]
+        ret i16 %tmp.1
+}
diff --git a/test/CodeGen/Alpha/zapnot2.ll b/test/CodeGen/Alpha/zapnot2.ll
new file mode 100644
index 0000000..d026edd
--- /dev/null
+++ b/test/CodeGen/Alpha/zapnot2.ll
@@ -0,0 +1,10 @@
+; Make sure this testcase codegens to the zapnot instruction
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha | grep zapnot
+
+implementation   ; Functions:
+
+long %bar(long %x) {
+entry:
+	%tmp.1 = and long %x, 16711935 		; <long> [#uses=1]
+	ret long %tmp.1
+}
diff --git a/test/CodeGen/Alpha/zapnot3.ll b/test/CodeGen/Alpha/zapnot3.ll
new file mode 100644
index 0000000..c106b6d
--- /dev/null
+++ b/test/CodeGen/Alpha/zapnot3.ll
@@ -0,0 +1,15 @@
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha | grep zapnot
+
+;demanded bits mess up this mask in a hard to fix way
+;ulong %foo(ulong %y) {
+;        %tmp = and ulong %y,  65535
+;        %tmp2 = shr ulong %tmp,  ubyte 3
+;        ret ulong %tmp2
+;}
+
+ulong %foo2(ulong %y) {
+        %tmp = shr ulong %y, ubyte 3            ; <ulong> [#uses=1]
+        %tmp2 = and ulong %tmp, 8191            ; <ulong> [#uses=1]
+        ret ulong %tmp2
+}
+
diff --git a/test/CodeGen/Alpha/zapnot4.ll b/test/CodeGen/Alpha/zapnot4.ll
new file mode 100644
index 0000000..b805607
--- /dev/null
+++ b/test/CodeGen/Alpha/zapnot4.ll
@@ -0,0 +1,8 @@
+; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha | grep zapnot
+
+ulong %foo(ulong %y) {
+        %tmp = shl ulong %y, ubyte 3            ; <ulong> [#uses=1]
+        %tmp2 = and ulong %tmp, 65535            ; <ulong> [#uses=1]
+        ret ulong %tmp2
+}
+