[llvm-bugs] [Bug 40730] New: [X86][AVX] lowerShuffleAsLanePermuteAndPermute - incomplete lane shuffle mask

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Feb 14 06:16:11 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=40730

            Bug ID: 40730
           Summary: [X86][AVX] lowerShuffleAsLanePermuteAndPermute -
                    incomplete lane shuffle mask
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: llvm-dev at redking.me.uk
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, spatel+llvm at rotateright.com

https://gcc.godbolt.org/z/tLJJE0

define <8 x i32> @shuffle_v8i32_0dcd3f14(<8 x i32> %a, <8 x i32> %b) {
  %shuffle = shufflevector <8 x i32> %a, <8 x i32> %b, <8 x i32> <i32 0, i32
13, i32 12, i32 13, i32 3, i32 15, i32 1, i32 4>
  ret <8 x i32> %shuffle
}

define <8 x i32> @shuffle_v8i32_0dcd3f14_constant(<8 x i32> %a0)  {
  %res = shufflevector <8 x i32> %a0, <8 x i32> <i32 9, i32 10, i32 11, i32 12,
i32 13, i32 14, i32 15, i32 16>, <8 x i32> <i32 0, i32 13, i32 12, i32 13, i32
3, i32 15, i32 1, i32 4>
  ret <8 x i32> %res
}

When the shuffle gets lowered, the constant argument gets incorrectly folded.
This appears to be due to the shuffle mask that (correctly) lowers to
vperm2f128, containing undef elements in the wrong place that allows undef
propagation that leads to incorrect constant folding.

shuffle_v8i32_0dcd3f14:
  vextractf128 $1, %ymm0, %xmm2
  vblendps $1, %xmm2, %xmm0, %xmm2 # xmm2 = xmm2[0],xmm0[1,2,3]
  vpermilps $23, %xmm2, %xmm2 # xmm2 = xmm2[3,1,1,0]
  vinsertf128 $1, %xmm2, %ymm0, %ymm0
  vperm2f128 $17, %ymm0, %ymm1, %ymm1 # ymm1 = ymm1[2,3,2,3]
  vpermilpd $4, %ymm1, %ymm1 # ymm1 = ymm1[0,0,3,2]
  vblendps $209, %ymm0, %ymm1, %ymm0 # ymm0 =
ymm0[0],ymm1[1,2,3],ymm0[4],ymm1[5],ymm0[6,7]
  retq

.LCPI0_0:
  .quad 60129542157 # 0x‭0000000E0000000D‬
  .quad 60129542157 # 0x‭0000000E0000000D‬
  .zero 8   <-- INCORRECT - should be 0x‭0000000F00000000
  .quad 60129542157 # 0x‭0000000E0000000D‬
shuffle_v8i32_0dcd3f14_constant:
  vextractf128 $1, %ymm0, %xmm1
  vblendps $1, %xmm1, %xmm0, %xmm1 # xmm1 = xmm1[0],xmm0[1,2,3]
  vpermilps $23, %xmm1, %xmm1 # xmm1 = xmm1[3,1,1,0]
  vinsertf128 $1, %xmm1, %ymm0, %ymm0
  vblendps $46, .LCPI0_0(%rip), %ymm0, %ymm0 # ymm0 =
ymm0[0],mem[1,2,3],ymm0[4],mem[5],ymm0[6,7]
  retq

Reduced from an internal fuzz test.

-- 
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/20190214/3013c647/attachment.html>


More information about the llvm-bugs mailing list