[LLVMbugs] [Bug 17764] New: llc generates wrong asm at AVX2 from instructions trunc + select

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Nov 1 03:52:07 PDT 2013


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

            Bug ID: 17764
           Summary: llc generates wrong asm at AVX2 from instructions
                    trunc + select
           Product: tools
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: llc
          Assignee: unassignedbugs at nondot.org
          Reporter: ili.filippov at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Reproducer for this issue:

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

; Function Attrs: nounwind
define <16 x i16> @foo() {
allocas:
  %mask_1 = alloca <16 x i32>
  %second = alloca <16 x i16>
  %first = alloca <16 x i16>

  store <16 x i32> <i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32
-1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1>, <16 x
i32>* %mask_1
  store <16 x i16> <i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16
2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2>, <16 x i16>* %first
  store <16 x i16> <i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16
7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7>, <16 x i16>* %second

  %first_load = load <16 x i16>* %first
  %second_load = load <16 x i16>* %second
  %mask_2 = load <16 x i32>* %mask_1

  %mask_3 = trunc <16 x i32> %mask_2 to <16 x i1>
  %result = select <16 x i1> %mask_3, <16 x i16> %first_load, <16 x i16>
%second_load

  ret <16 x i16> %result
}

At AVX2 llc generates asm code which ends in instuction:
vpblendvb       %ymm2, %ymm0, %ymm1, %ymm0
where ymm2 = 16 x -1, ymm0 = 16 x 7, and ymm1 = 16 x 2.
This instruction makes ymm0 = 16 x 7 and it is wrong because LLVM instrunction
select <16 x i1> %mask_3, <16 x i16> %first_load, <16 x i16> %second_load
should return first_load which is 16 x 2.

So function returns 16 x 7 instead of 16 x 2

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131101/76e25dea/attachment.html>


More information about the llvm-bugs mailing list