<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 - ARM NEON vld3_u8 incorrect optimization"
   href="https://bugs.llvm.org/show_bug.cgi?id=46105">46105</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>ARM NEON vld3_u8 incorrect optimization
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>10.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>guilder13@yandex-team.ru
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Not sure if it's shortest snippet, but it's much less than original.

#include "arm_neon.h"

typedef unsigned char uint8;
typedef unsigned short uint16;
typedef short int16;

inline void decompressColor(const uint8 color_RGB444[3], uint8 color[3])
{
  color[0] = (color_RGB444[0] << (8 - 4)) | (color_RGB444[0] >> (4 - (8-4)) );
  color[1] = (color_RGB444[1] << (8 - 4)) | (color_RGB444[1] >> (4 - (8-4)) );
  color[2] = (color_RGB444[2] << (8 - 4)) | (color_RGB444[2] >> (4 - (8-4)) );
}

#pragma clang optimize off
uint8x8_t noopt(uint8x8_t possible_colors_v[4][3], uint8x8x3_t rgba_u8[2])
{
  // fake usage
}
#pragma clang optimize on

int calculateError59T_NEON(const uint8* srcimg, uint8 (colorsRGB444)[2][3],
uint8 &distance, unsigned int &pixel_indices,
                           int best_block_error = 65535)
{
  // Problem line
  uint8x8x3_t rgba_u8[2] = { vld3_u8(srcimg), vld3_u8(srcimg + 3 * 8) };

  uint8 color0[3];
  uint8 color1[3];
  decompressColor(colorsRGB444[0], color0);
  decompressColor(colorsRGB444[1], color1);
  uint8x8_t possible_colors_v[4][3];
  possible_colors_v[0][0] = vdup_n_u8(color0[0]);
  possible_colors_v[0][1] = vdup_n_u8(color0[1]);
  possible_colors_v[0][2] = vdup_n_u8(color0[2]);
  possible_colors_v[2][0] = vdup_n_u8(color1[0]);
  possible_colors_v[2][1] = vdup_n_u8(color1[1]);
  possible_colors_v[2][2] = vdup_n_u8(color1[2]);

  uint32x4_t best_block_error_v = vdupq_n_u32(best_block_error);

  noopt(possible_colors_v, rgba_u8);

  return best_block_error_v[0];
}

Not optimized code is too long to show it (around 37 lines), because of
intrinsics.
Optimization without surroundings is correct.

ld3     {v0.8b-v2.8b}, [x0], #24
stp     d0, d1, [x1]
str     d2, [x1,#16]
ld3     {v0.8b-v2.8b}, [x0]
stp     d0, d1, [x1,#24]
str     d2, [x1,#40]

Optimization with surrounding code.

ld3     {v1.8b-v3.8b}, [x0], #24
...
stp     d0, d1, [x29,#-48]
ld3     {v0.8b-v2.8b}, [x0]
...
stp     d3, d0, [x29,#-32]
stp     d1, d2, [x29,#-16]

As you can see, it loads first part in v1-3, then stores d0, d1. Where d0 was
not even loaded, and so on.

We are using now these revisions.
CLANG_REVISION = '4e0d9925d6a3561449bdd8def27fd3f3f1b3fb9f'
CLANG_SVN_REVISION = 'n346557'
CLANG_SUB_REVISION = 2</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>