<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [X86][AVX] lowerShuffleAsLanePermuteAndPermute - incomplete lane shuffle mask"
   href="https://bugs.llvm.org/show_bug.cgi?id=40730">40730</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[X86][AVX] lowerShuffleAsLanePermuteAndPermute - incomplete lane shuffle mask
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: X86
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>llvm-dev@redking.me.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre><a href="https://gcc.godbolt.org/z/tLJJE0">https://gcc.godbolt.org/z/tLJJE0</a>

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 # 0x0000000E0000000D
  .quad 60129542157 # 0x0000000E0000000D
  .zero 8   <-- INCORRECT - should be 0x0000000F00000000
  .quad 60129542157 # 0x0000000E0000000D
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.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>