blob: 4c8fe74cbd79d49237a99f142dfe47cf11617ee0 [file] [log] [blame]
Tanya Lattner2393a242004-11-06 23:08:26 +00001; RUN: llvm-as -f %s -o - | llc
2
Vikram S. Advea7a1c7e2002-07-10 21:54:05 +00003; Test that a negative constant smaller than 64 bits (e.g., int)
4; is correctly implemented with sign-extension.
5; In particular, the current code generated is:
6;
7; main:
8; .L_main_LL_0:
9; save %o6, -224, %o6
10; setx .G_fmtArg_1, %o1, %o0
11; setuw 1, %o1 ! i = 1
12; setuw 4294967295, %o3 ! THE BUG: 0x00000000ffffffff
13; setsw 0, %i0
14; add %i6, 1999, %o2 ! fval
15; add %o1, %g0, %o1
16; add %o0, 0, %o0
17; mulx %o1, %o3, %o1 ! ERROR: 0xffffffff; should be -1
18; add %o1, 3, %o1 ! ERROR: 0x100000002; should be 0x2
19; mulx %o1, 12, %o3 !
20; add %o2, %o3, %o3 ! produces bad address!
21; call printf
22; nop
23; jmpl %i7+8, %g0
24; restore %g0, 0, %g0
25;
26; llc produces:
27; ioff = 2 fval = 0xffffffff7fffec90 &fval[2] = 0xb7fffeca8
28; instead of:
29; ioff = 2 fval = 0xffffffff7fffec90 &fval[2] = 0xffffffff7fffeca8
30;
31
32%Results = type { float, float, float }
33
34%fmtArg = internal global [39 x sbyte] c"ioff = %u\09fval = 0x%p\09&fval[2] = 0x%p\0A\00"; <[39 x sbyte]*> [#uses=1]
35
36implementation
37
38declare int "printf"(sbyte*, ...)
39
40int "main"()
41begin
42 %fval = alloca %Results, uint 4
43 %i = add uint 1, 0 ; i = 1
44 %iscale = mul uint %i, 4294967295 ; i*-1 = -1
45 %ioff = add uint %iscale, 3 ; 3+(-i) = 2
Chris Lattner30e2d912003-09-09 18:14:37 +000046 %ioff = cast uint %ioff to long
47 %fptr = getelementptr %Results* %fval, long %ioff ; &fval[2]
48 %castFmt = getelementptr [39 x sbyte]* %fmtArg, long 0, long 0
Vikram S. Advea7a1c7e2002-07-10 21:54:05 +000049 call int (sbyte*, ...)* %printf(sbyte* %castFmt, uint %ioff, %Results* %fval, %Results* %fptr)
50 ret int 0
51end