<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 - Miscompile with -opt -loop-vectorize after 8871a4b4cab8"
   href="https://bugs.llvm.org/show_bug.cgi?id=48832">48832</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Miscompile with -opt -loop-vectorize after 8871a4b4cab8
          </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>Loop Optimizer
          </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=24405" name="attach_24405" title="bbi-51947.ll reproducer">attachment 24405</a> <a href="attachment.cgi?id=24405&action=edit" title="bbi-51947.ll reproducer">[details]</a></span>
bbi-51947.ll reproducer

With
 opt -mtriple=s390x-unknown-linux -mcpu=z13 -loop-vectorize -S -o -
bbi-51947.ll

I get a
 store <4 x i32> poison, <4 x i32>* %6, align 1

which I htink is incorrect.

This starts happening with 8871a4b4cab8:


    [Constant] Update ConstantVector::get to return poison if all input elems
are poison

    The diff was reviewed at D93994

Before the patch I got

store <4 x i32> zeroinitializer, <4 x i32>* %6, align 1

The input is

%arrayt = type [64 x i32]

@v_146 = external global %arrayt, align 1

define void @foo() {
entry:
  br label %for.cond

for.cond:                                         ; preds = %cond.end, %entry
  %storemerge = phi i16 [ 0, %entry ], [ %inc, %cond.end ]
  %cmp = icmp slt i16 %storemerge, 15
  br i1 %cmp, label %for.body, label %for.end

for.body:                                         ; preds = %for.cond
  br i1 true, label %cond.false, label %land.rhs

land.rhs:                                         ; preds = %for.body
  br i1 poison, label %cond.end, label %cond.false

cond.false:                                       ; preds = %for.body,
%land.rhs
  br label %cond.end

cond.end:                                         ; preds = %land.rhs,
%cond.false
  %cond = phi i32 [ 0, %cond.false ], [ 1, %land.rhs ]
  %arrayidx = getelementptr inbounds %arrayt, %arrayt* @v_146, i16 0, i16
%storemerge
  store i32 %cond, i32* %arrayidx, align 1
  %inc = add nsw i16 %storemerge, 1
  br label %for.cond

for.end:                                          ; preds = %for.cond
  ret void
}

Note the

for.body:                                         ; preds = %for.cond
  br i1 true, label %cond.false, label %land.rhs

land.rhs:                                         ; preds = %for.body
  br i1 poison, label %cond.end, label %cond.false

%land.rhs is dead due to the "br i1 true" branch, but I think it still is
involved somehow in making the stored value poison with this patch.</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>