<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 - Inserting an element to an undef vector"
   href="https://bugs.llvm.org/show_bug.cgi?id=39685">39685</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Inserting an element to an undef vector
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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>Backend: WebAssembly
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>aheejin@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>```
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"                          
target triple = "wasm32-unknown-unknown"                                        

define <16 x i8> @test(i8 %x) {                                                 
  %v = insertelement <16 x i8> undef, i8 %x, i32 0                              
  ret <16 x i8> %v                                                              
}
```

If you compile the code above with the command
llc -asm-verbose=false -wasm-keep-registers -wasm-disable-explicit-locals
-mattr=+simd128,+sign-ext test.ll

The result will be like
```
splat_v16i8:                                                                    
  .param    i32                                                                 
  .result   v128                                                                
  i8x16.splat  $push0=, $0                                                      
  i8x16.replace_lane  $push1=, $pop0, 1, $0                                     
  i8x16.replace_lane  $push2=, $pop1, 2, $0                                     
  i8x16.replace_lane  $push3=, $pop2, 3, $0                                     
  i8x16.replace_lane  $push4=, $pop3, 4, $0                                     
  i8x16.replace_lane  $push5=, $pop4, 5, $0                                     
  i8x16.replace_lane  $push6=, $pop5, 6, $0                                     
  i8x16.replace_lane  $push7=, $pop6, 7, $0                                     
  i8x16.replace_lane  $push8=, $pop7, 8, $0                                     
  i8x16.replace_lane  $push9=, $pop8, 9, $0                                     
  i8x16.replace_lane  $push10=, $pop9, 10, $0                                   
  i8x16.replace_lane  $push11=, $pop10, 11, $0                                  
  i8x16.replace_lane  $push12=, $pop11, 12, $0                                  
  i8x16.replace_lane  $push13=, $pop12, 13, $0                                  
  i8x16.replace_lane  $push14=, $pop13, 14, $0                                  
  i8x16.replace_lane  $push15=, $pop14, 15, $0                                  
  end_function 
```

What does wasm backend do for undef elements? Does it initialize them to zero?

But anyway here, doesn't the first instruction, splat, set all elements to the
value give by the argument? I'm not sure why all 'replace_lane's below try to
set each element one by one with the same value, which was supposed to be done
anyway by the first splat instruction.</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>