<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 - vector ZERO_EXTEND gets scalarized"
   href="https://bugs.llvm.org/show_bug.cgi?id=47132">47132</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>vector ZERO_EXTEND gets scalarized
          </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>Backend: SystemZ
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>paulsson@linux.vnet.ibm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=23844" name="attach_23844" title="test case">attachment 23844</a> <a href="attachment.cgi?id=23844&action=edit" title="test case">[details]</a></span>
test case

The (first) DAGCombiner will replace a DAG like:

       t8: v2f64 = BUILD_VECTOR ConstantFP:f64<0.000000e+00>,
ConstantFP:f64<0.000000e+00>
     t10: v2i1 = setcc t2, t8, setoeq:ch
   t11: v2i32 = zero_extend t10

in visitZERO_EXTEND() to

          t8: v2f64 = BUILD_VECTOR ConstantFP:f64<0.000000e+00>,
ConstantFP:f64<0.000000e+00>
        t16: v2i64 = setcc t2, t8, setoeq:ch
      t17: v2i32 = truncate t16
     t19: v2i32 = BUILD_VECTOR Constant:i32<1>, Constant:i32<1>
   t20: v2i32 = and t17, t19

This works only with a SETCC operand (DAGCombiner.cpp:10482), so an OR of two
SETCC results is currently unhandled, and the type legalizer will then
scalarize the zero_extend:

t11: v2i32 = zero_extend t10
 WidenVectorResult()
   WidenVecRes_Convert() -> scalarization

Zero extending a vector of i1 is not quite simple, as it involves first
truncating / extending the vector select result, and then and:ing each element
with 1. Perhaps it would a custom DAG combine (pre-legalize types) is the right
approach given this? Or coudl the common-code that currently just handles a
SETCC operand be extended to handle this type of case, maybe?

The DAGTypeLegalizer wants to either widen the InVT (v2i1) or have the
InWidenVT to be legal (v4i1), or it will scalarize. I am not sure if that could
be made to work, but at first glance it doesn't look right.


llc -O3 -mcpu=z14 -o - ./tc_or_i1.ll -debug-only="isel,legalize-types"</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>