[llvm-bugs] [Bug 45780] New: Using an enum instead of literal + optimizing causes backend to fail with an operand error

via llvm-bugs llvm-bugs at lists.llvm.org
Sat May 2 20:03:09 PDT 2020


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

            Bug ID: 45780
           Summary: Using an enum instead of literal + optimizing causes
                    backend to fail with an operand error
           Product: clang
           Version: 10.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: Levo.DeLellis at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Created attachment 23436
  --> https://bugs.llvm.org/attachment.cgi?id=23436&action=edit
test code to reproduce error

I didn't see this report with a quick search. Here's a minimal reproducible
example. The error is `input128 & AlignMask` inside of __builtin_shufflevector.
Using literal 15 or the define doesn't cause the problem. No optimizing doesn't
cause the problem. O1, 2 and 3 causes the error.

$ cat test.cpp 
//clang++-10 -O2 test.cpp
//clang 9 also crashes, must optimize
#include <emmintrin.h>
#include <immintrin.h>

typedef unsigned char u8;
typedef unsigned short u16;

typedef unsigned char u8v16 __attribute__ ((vector_size (16)));

enum { AlignMask=15 };
//#define AlignMask 15

u8  data[1024*1024*100] __attribute__ ((aligned(64)));
u16 data_out[sizeof(data)] __attribute__ ((aligned(64)));
u8 token_len[sizeof(data)] __attribute__ ((aligned(64)));
u8v16 HighTable = {3, 0, 33, 12, 4, 20, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4};
u8v16 LowTable = {13, 12, 12, 12, 12, 12, 12, 12, 12, 13, 6, 4, 4, 5, 36, 20};

void Test()
{
        auto pdata_end = data+sizeof(data);
        for(auto pinput=data; pinput<pdata_end; pinput+=16)
        {
                auto input128 = (u8v16)_mm_load_si128((__m128i*)pinput);
                const auto lo_val = __builtin_shufflevector(LowTable, input128
& AlignMask);

                _mm_store_si128((__m128i*)token_len, lo_val);
        }
}
int main()
{
        Test();
        return 0;
}

$ clang++-10 -O2 test.cpp
fatal error: error in backend: Do not know how to split this operator's
operand!

clang: error: clang frontend command failed with exit code 70 (use -v to see
invocation)
clang version 10.0.0-4ubuntu1 
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to
https://bugs.llvm.org/ and include the crash backtrace, preprocessed source,
and associated run script.
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/test-58cf11.cpp
clang: note: diagnostic msg: /tmp/test-58cf11.sh
clang: note: diagnostic msg: 

********************

-- 
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/20200503/e8145792/attachment.html>


More information about the llvm-bugs mailing list