<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 - r358887 causes fatal error: error in backend: Cannot emit physreg copy instruction"
   href="https://bugs.llvm.org/show_bug.cgi?id=41619">41619</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>r358887 causes fatal error: error in backend: Cannot emit physreg copy instruction
          </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>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>Common Code Generator Code
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>rtrieu@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>$ cat test.ii
using Vec = float __attribute__((__vector_size__(16)));
Vec getVector();
Vec makeVector(float f) {
  float g;
  return {g, f, f};
}

struct A {
  union {
    Vec v;
    float arr[4];
  };
  A() : v(getVector()) {}
  A(Vec k) : v(k) {}
};

struct B : A {
  B() {}
  B(float f) : A(makeVector(f)) {}
  float &operator[](int i) { return arr[i]; }
};


struct C {
  B d[2];
  C() {}
  C(B b0, B b1) : d{b0, b1} {}

  B &operator[](int i) { return d[i]; }

  void Bar(C);

  C calculate() {
    C ret;
    for (int i = 0; i < 3; i++)
      for (int j = 0; j < 3; j++)
        ret[i][j] = d[j][i];
    return ret;
  }
};

void run(B b) {
  C c1 = C(B(), B(b[0]));
  C c2 = c1.calculate();
  c2.Bar(c1);
}

$ clang -mavx2 -O2 test.ii
fatal error: error in backend: Cannot emit physreg copy instruction
clang-9: error: clang frontend command failed with exit code 70

$ clang -mavx2 -O2 test.ii -v
"/usr/local/bin/clang-9" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj
-disable-free -disable-llvm-verifier -discard-value-names -main-file-name
test.ii -mrelocation-model static -mthread-model posix -fmath-errno
-masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array
-target-cpu x86-64 -target-feature +avx2 -dwarf-column-info
-debugger-tuning=gdb -momit-leaf-frame-pointer -v -resource-dir
/usr/local/lib/clang/9.0.0 -O2 -fdeprecated-macro -fdebug-compilation-dir
/usr/local/crash -ferror-limit 19 -fmessage-length 80 -fobjc-runtime=gcc
-fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics
-vectorize-loops -vectorize-slp -o /tmp/test-4ae44d.o -x c++-cpp-output test.ii
-faddrsig</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>