https://bugs.llvm.org/show_bug.cgi?id=39685

            Bug ID: 39685
           Summary: Inserting an element to an undef vector
           Product: libraries
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: WebAssembly
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

```
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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to