llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

AVX512 bug with mask size

Open llvmbot opened this issue 11 years ago • 1 comments

Bugzilla Link 23634
Resolution FIXED
Resolved on May 26, 2015 06:33
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @dbabokin,@delena

Extended Description

; 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

llvmbot avatar May 22 '15 09:05 llvmbot

Fixed in 238195.

delena avatar May 26 '15 13:05 delena