[LLVMbugs] [Bug 10907] New: X86 vector comparisons wrong way round!

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Sep 11 08:45:38 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=10907

           Summary: X86 vector comparisons wrong way round!
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: baldrick at free.fr
                CC: llvmbugs at cs.uiuc.edu


As the following testcase shows, trying to compute the maximum of two vectors
actually computes the minimum.  It looks like codegen gets the operands the
wrong way round.

$ llc -promote-elements max.ll
$ gcc -o max max.s
$ ./max
max: 1 1 (should be 2 2)

Testcase:


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

@str = private constant [28 x i8] c"max: %g %g (should be 2 2)\0A\00", align 1

declare i32 @printf(i8* noalias nocapture, ...) nounwind

define <2 x double> @max(<2 x double> %x, <2 x double> %y) {
  %max_is_x = fcmp oge <2 x double> %x, %y
  %max = select <2 x i1> %max_is_x, <2 x double> %x, <2 x double> %y
  ret <2 x double> %max
}

define i32 @main() {
  %m = call <2 x double> @max(<2 x double> <double 1.0, double 1.0>, <2 x
double> <double 2.0, double 2.0>)
  %a = extractelement <2 x double> %m, i32 0
  %b = extractelement <2 x double> %m, i32 1
  %t = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([28 x i8]*
@str, i64 0, i64 0), double %a, double %b)
  ret i32 0
}

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list