summaryrefslogtreecommitdiff
path: root/test/CodeGen/Generic/negintconst.ll
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/negintconst.ll
parent975f6d4f4477a68f9b322843a1bf2ebc24214b3a (diff)
downloadllvm-a7a1c7e9719a4358521035be9965603eb1f429a6.tar.gz
llvm-a7a1c7e9719a4358521035be9965603eb1f429a6.tar.bz2
llvm-a7a1c7e9719a4358521035be9965603eb1f429a6.tar.xz
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/negintconst.ll')
-rw-r--r--test/CodeGen/Generic/negintconst.ll48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/CodeGen/Generic/negintconst.ll b/test/CodeGen/Generic/negintconst.ll
new file mode 100644
index 0000000000..9e671b095b
--- /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