[LLVMdev] problem with sgt's on Sparc machine

Duncan Sands baldrick at free.fr
Thu Sep 15 10:20:57 PDT 2011


Hi,

> target datalayout =
> "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
> target triple = "i386-pc-linux-gnu"

if you are using this target data layout and triple on a Sparc machine,
I'm not surprised you get wrong results.

Ciao, Duncan.

>
> @P = global i32 1
> @dP = global i32 1
>
> @.str = private constant [4 x i8] c"%d\0A\00", align 1
>
> define i32 @main() nounwind {
>
> entry:
>      %. = load i32* @P, align 4
>      %t1 = tail call i32 (i8*, ...)* @printf(i8* noalias getelementptr inbounds
> ([4 x i8]* @.str, i32 0, i32 0), i32 %. ) nounwind
>      %d. = load i32* @dP, align 4
>      %t2 = tail call i32 (i8*, ...)* @printf(i8* noalias getelementptr inbounds
> ([4 x i8]* @.str, i32 0, i32 0), i32 %d. ) nounwind
>      %0 = icmp sgt i32 %., 0
>    %1 = tail call i32 (i8*, ...)* @printf(i8* noalias getelementptr inbounds ([4
> x i8]* @.str, i32 0, i32 0), i1 %0 ) nounwind
>      %2 = icmp sgt i32 %d., 0
>      %3 = tail call i32 (i8*, ...)* @printf(i8* noalias getelementptr inbounds
> ([4 x i8]* @.str, i32 0, i32 0), i1 %2 ) nounwind
>      %t3 = icmp eq i32 %d., %d.
>      %t4 = tail call i32 (i8*, ...)* @printf(i8* noalias getelementptr inbounds
> ([4 x i8]* @.str, i32 0, i32 0), i1 %t3 ) nounwind
>      %4 = icmp sgt i32 1, 0
>      %5 = icmp sgt i32 1, 0
>      %6 = tail call i32 (i8*, ...)* @printf(i8* noalias getelementptr inbounds
> ([4 x i8]* @.str, i32 0, i32 0), i1 %4 ) nounwind
>      %7 = tail call i32 (i8*, ...)* @printf(i8* noalias getelementptr inbounds
> ([4 x i8]* @.str, i32 0, i32 0), i1 %5 ) nounwind
>    ret i32 undef
> }
>
> declare i32 @printf(i8* nocapture, ...) nounwind
> -------------------------------------------------------------------------------------------------------------------
>
> On Sparc I get:
> 1
> 1
> 0
> 0
> 1
> 1
> 1
>
> On X86 I get all 1's which I believe is correct.
>
> I used the following command to compile on sparc:
> llc -march=sparc llvm_print.bc -o llvm_print.s   ( on a x86 machine)
> /usr/sfw/bin/gcc -mcpu=v9 -mtune=v9 llvm_print.s -o llvm_print  (on sparc)
>
>
> Could anyone give me some clue about what's going on? Is 'sgt' not working for
> loaded values?
>
> Thanks,
>
> Christine
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list