<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - AVX512 bug with mask size" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23634&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=6dFYtOQe5YXFvMu0o--FqWxEtxLBGWrSMbiHnni14Vw&s=DslbNq-1QUh8v00vvk8hiRR9qdvmakwrkvbjgmRag-c&e=">23634</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>AVX512 bug with mask size
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>tools
          </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>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>llc
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>anton.mitrokhin@phystech.edu
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>; Reproducer
; First eight elements are computed correctly, while elements from 8 to 15 
; incorrect if use math with masks

;test.ll:
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"


; Function Attrs: nounwind
define void @f_fu(float* noalias nocapture %ret, float* noalias nocapture
readonly %aa, float %b) #1 {
allocas:
  %ptr_cast_for_load = bitcast float* %aa to <16 x float>*
  %ptr_masked_load.39 = load <16 x float>, <16 x float>* %ptr_cast_for_load,
align 4, !filename !1, !first_line !2, !first_column !3, !last_line !2,
!last_column !4
  %b_load_to_int32 = fptosi float %b to i32
  %b_load_to_int32_broadcast_init = insertelement <16 x i32> undef, i32
%b_load_to_int32, i32 0
  %b_load_to_int32_broadcast = shufflevector <16 x i32>
%b_load_to_int32_broadcast_init, <16 x i32> undef, <16 x i32> zeroinitializer
  %mul__b_load9 = fmul float %b, 2.000000e+00
  %mul__b_load9_to_int32 = fptosi float %mul__b_load9 to i32
  %mul__b_load9_to_int32_broadcast_init = insertelement <16 x i32> undef, i32
%mul__b_load9_to_int32, i32 0
  %mul__b_load9_to_int32_broadcast = shufflevector <16 x i32>
%mul__b_load9_to_int32_broadcast_init, <16 x i32> undef, <16 x i32>
zeroinitializer


  %a_load_to_int32 = fptosi <16 x float> %ptr_masked_load.39 to <16 x i32>; <16
x i32> <i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10,
i32 11, i32 12, i32 13, i32 14, i32 15, i32 16>
  %div_v019_load_ = sdiv <16 x i32> %mul__b_load9_to_int32_broadcast, <i32 2,
i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2,
i32 2, i32 2, i32 2, i32 2>


 %v1.i = select <16 x i1> <i1 false, i1 true, i1 false, i1 true, i1 false, i1
true, i1 false, i1 true, i1 false, i1 true, i1 false, i1 true, i1 false, i1
true, i1 false, i1 true>, <16 x i32> <i32 2, i32 3, i32 4, i32 5, i32 6, i32 7,
i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17>,
<16 x i32> %a_load_to_int32


  %foo_test = add <16 x i32> %div_v019_load_, %b_load_to_int32_broadcast ; <5,
5, 5, 5, ...> + <5, 5, 5, 5 ...> = <10, 10, 10, ...>


  %add_struct_offset_y_struct_offset33_x = add <16 x i32> %foo_test, %v1.i ;
<10, 10, 10 ...> + <1, 3, 3, 5, 5, 7, 7, 9, 9 ...>



  %add_struct_offset_y_struct_offset33_x_to_float = sitofp <16 x i32>
%add_struct_offset_y_struct_offset33_x to <16 x float>
  %ptrcast = bitcast float* %ret to <16 x float>*
  store <16 x float> %add_struct_offset_y_struct_offset33_x_to_float, <16 x
float>* %ptrcast, align 4, !filename !1, !first_line !5, !first_column !6,
!last_line !5, !last_column !7
  ret void
}


; Function Attrs: nounwind
declare void @llvm.lifetime.start(i64, i8* nocapture) #1

; Function Attrs: nounwind
declare void @llvm.lifetime.end(i64, i8* nocapture) #1

attributes #0 = { nounwind readnone }
attributes #1 = { nounwind }

!llvm.ident = !{!0}

!0 = !{!"clang version 3.7.0 (trunk 237307) (llvm/trunk 237306)"}
!1 = !{!""}
!2 = !{i32 7}
!3 = !{i32 15}
!4 = !{i32 31}
!5 = !{i32 13}
!6 = !{i32 5}
!7 = !{i32 22}
!8 = !{i32 17}


//main.cpp:
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>


extern "C" {
    extern void f_fu(float *result, float *a, float b);
}


int main(int argc, char *argv[]) {

    float returned_result[16];
    float vfloat[16];

    for (int i = 0; i < 16; ++i) {
        vfloat[i] = i+1;
    }

    f_fu(returned_result, vfloat, 5);

    float expected_result[16];
    for (int i = 0; i < 16; ++i) {
        expected_result[i] = 10 + i + 1;
        if (i & 1) expected_result[i] ++;
    }


    int errors = 0;
    for (int i = 0; i < 16; ++i) {
        if (returned_result[i] != expected_result[i]) {

            printf("%s: value %d disagrees: returned %f [%a], expected %f
[%a]\n",
                   argv[0], i, returned_result[i], returned_result[i],
                   expected_result[i], expected_result[i]);
            ++errors;
        }
        else {
            printf("%s: value %d    agrees: returned %f [%a], expected %f
[%a]\n",
                   argv[0], i, returned_result[i], returned_result[i],
                   expected_result[i], expected_result[i]);
        }
    }


    return errors > 0;
}

Run with:
clang++ -O0 -march=knl main.cpp ./test.ll -o ./test.run
sde -knl -- ./test.run</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>