48 lines · plain
1; RUN: llc < %s2 3; 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, %o610; setx .G_fmtArg_1, %o1, %o011; setuw 1, %o1 ! i = 112; setuw 4294967295, %o3 ! THE BUG: 0x00000000ffffffff13; setsw 0, %i014; add %i6, 1999, %o2 ! fval15; add %o1, %g0, %o116; add %o0, 0, %o017; mulx %o1, %o3, %o1 ! ERROR: 0xffffffff; should be -118; add %o1, 3, %o1 ! ERROR: 0x100000002; should be 0x219; mulx %o1, 12, %o3 ! 20; add %o2, %o3, %o3 ! produces bad address!21; call printf22; nop 23; jmpl %i7+8, %g024; restore %g0, 0, %g025; 26; llc produces:27; ioff = 2 fval = 0xffffffff7fffec90 &fval[2] = 0xb7fffeca828; instead of:29; ioff = 2 fval = 0xffffffff7fffec90 &fval[2] = 0xffffffff7fffeca830; 31 %Results = type { float, float, float }32@fmtArg = internal global [39 x i8] c"ioff = %u\09fval = 0x%p\09&fval[2] = 0x%p\0A\00" ; <ptr> [#uses=1]33 34declare i32 @printf(ptr, ...)35 36define i32 @main() {37 %fval = alloca %Results, i32 4 ; <ptr> [#uses=2]38 %i = add i32 1, 0 ; <i32> [#uses=1]39 %iscale = mul i32 %i, -1 ; <i32> [#uses=1]40 %ioff = add i32 %iscale, 3 ; <i32> [#uses=2]41 %ioff.upgrd.1 = zext i32 %ioff to i64 ; <i64> [#uses=1]42 %fptr = getelementptr %Results, ptr %fval, i64 %ioff.upgrd.1 ; <ptr> [#uses=1]43 %castFmt = getelementptr [39 x i8], ptr @fmtArg, i64 0, i64 0 ; <ptr> [#uses=1]44 call i32 (ptr, ...) @printf( ptr %castFmt, i32 %ioff, ptr %fval, ptr %fptr ) ; <i32>:1 [#uses=0]45 ret i32 046}47 48