<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 - LoopVectorizer triggers "Instruction does not dominate all uses!" after r326079"
   href="https://bugs.llvm.org/show_bug.cgi?id=37248">37248</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LoopVectorizer triggers "Instruction does not dominate all uses!" after r326079
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>new bugs
          </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>Created <span class=""><a href="attachment.cgi?id=20226" name="attach_20226" title="reproducer">attachment 20226</a> <a href="attachment.cgi?id=20226&action=edit" title="reproducer">[details]</a></span>
reproducer

Running

 opt -loop-vectorize -S -o - tr15930.ll

with this commit gives:


Instruction does not dominate all uses!
  %25 = trunc i32 %offset.idx16 to i16
  %broadcast.splatinsert17 = insertelement <4 x i16> undef, i16 %25, i32 0
LLVM ERROR: Broken function found, compilation aborted!


Looking at the output after the loop vectorizer we get


*** IR Dump After Loop Vectorization ***
define void @f1() {
entry:
  br i1 false, label %scalar.ph, label %vector.scevcheck

vector.scevcheck:                                 ; preds = %entry
  %mul = call { i16, i1 } @llvm.umul.with.overflow.i16(i16 1, i16 undef)
  %mul.result = extractvalue { i16, i1 } %mul, 0
  %mul.overflow = extractvalue { i16, i1 } %mul, 1
  %0 = add i16 undef, %mul.result
  %1 = sub i16 undef, %mul.result
  %2 = icmp sgt i16 %1, undef
  %3 = icmp slt i16 %0, undef
  %4 = select i1 true, i1 %2, i1 %3
  %5 = or i1 %4, %mul.overflow
  %6 = or i1 false, %5
  br i1 %6, label %scalar.ph, label %vector.ph

vector.ph:                                        ; preds = %vector.scevcheck
  %broadcast.splatinsert17 = insertelement <4 x i16> undef, i16 %25, i32 0
  %broadcast.splat18 = shufflevector <4 x i16> %broadcast.splatinsert17, <4 x
i16> undef, <4 x i32> zeroinitializer
  br label %vector.body

[...]

pred.load.continue15:                             ; preds = %pred.load.if14,
%pred.load.continue13
  %24 = phi i32 [ undef, %pred.load.continue13 ], [ %23, %pred.load.if14 ]
  %offset.idx16 = sub i32 undef, %index
  %25 = trunc i32 %offset.idx16 to i16

If we follow the path

 entry -> vector.scevcheck -> vector.ph

we see that the def of %25 in pred.load.continue15 doesn't dominate the use in
vector.ph.</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>