<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 - Wrong promotion of vector to integer bitcast on big-endian targets"
   href="https://bugs.llvm.org/show_bug.cgi?id=44135">44135</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Wrong promotion of vector to integer bitcast on big-endian targets
          </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>enhancement
          </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>mikael.holmen@ericsson.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Reproducer:

;RUN: llc -O0 -mtriple=armebv7 -target-abi apcs -o - %s
-stop-before=finalize-isel | FileCheck %s

; Stop somewhere soon after isel.

@vec6_p = external global <6 x i16>

define i32 @foo() {
bb.0:
  %vec6 = load <6 x i16>, <6 x i16>* @vec6_p, align 1
  br label %bb.1

bb.1:
  %0 = bitcast <6 x i16> %vec6 to i96
  %1 = trunc i96 %0 to i32
  ret i32 %1
}

; CHECK-LABEL: bb.1.bb.1:
; CHECK:         [[REG0:%[0-9]+]]:qpr = VREV32q16 {{%[0-9]+}}
; CHECK:         [[REG1:%[0-9]+]]:dpr = COPY [[REG0]].dsub_1
; CHECK:         {{%[0-9]+}}:gpr = VGETLNi32 killed [[REG1]], 0


In the SelectionDAG printouts we see

Type-legalized selection DAG: %bb.1 'foo:bb.1'
SelectionDAG has 9 nodes:
  t0: ch = EntryToken
        t2: v8i16,ch = CopyFromReg t0, Register:v8i16 %0
      t17: v4i32 = bitcast t2
    t23: i32 = extract_vector_elt t17, Constant:i32<3>
  t8: ch,glue = CopyToReg t0, Register:i32 $r0, t23
  t9: ch = ARMISD::RET_FLAG t8, Register:i32 $r0, t8:1

and I think here the extract_vector_elt is wrong and extracts the value
from the wrong index.

The program program should return the 32 bits made up of the elements at
index 4 and 5 in the vec6 array, but with

    t23: i32 = extract_vector_elt t17, Constant:i32<3>

as far as I can tell, we will extract values that originally didn't even
exist in the vec6 vectore.

If we would instead extract the element at index 2 we would get the wanted
values.</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>