[llvm-bugs] [Bug 52084] New: Global storage is used in an array subscript task reduction

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Oct 5 09:00:48 PDT 2021


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

            Bug ID: 52084
           Summary: Global storage is used in an array subscript task
                    reduction
           Product: OpenMP
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Clang Compiler Support
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rpenacob at bsc.es
                CC: llvm-bugs at lists.llvm.org

Analizing the following code it can be seen that the storage returned by
__kmpc_task_reduction_get_th_data is not used when performing the add
operation.

// t1.c
int gArray[10];                                                                 
int main() {                                                                    
    #pragma omp taskgroup task_reduction(+: gArray[3])                          
    {                                                                           
        for (int i = 0; i < 1e5; ++i) {                                         
            #pragma omp task in_reduction(+: gArray[3])                         
            {                                                                   
                gArray[3]++;                                                    
            }                                                                   
        }                                                                       
    }                                                                           
} 

// clang -fopenmp -S -emit-llvm t1.c

The relevant portion of code is:
  %19 = call i8* @__kmpc_task_reduction_get_th_data(i32 %18, i8* %17, i8*
bitcast (i32* getelementptr inbounds ([10 x i32], [10 x i32]* @gArray, i64 0,
i64 3) to i8*)) #1
  %conv.i = bitcast i8* %19 to i32*
  %20 = getelementptr i32, i32* %conv.i, i64 sdiv exact (i64 sub (i64 ptrtoint
([10 x i32]* @gArray to i64), i64 ptrtoint (i32* getelementptr inbounds ([10 x
i32], [10 x i32]* @gArray, i64 0, i64 3) to i64)), i64 ptrtoint (i32*
getelementptr (i32, i32* null, i32 1) to i64))
  %21 = bitcast i32* %20 to [10 x i32]*
  %22 = load i32, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @gArray,
i64 0, i64 3), align 4
  %inc.i = add nsw i32 %22, 1
  store i32 %inc.i, i32* getelementptr inbounds ([10 x i32], [10 x i32]*
@gArray, i64 0, i64 3), align 4

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211005/b5482978/attachment-0001.html>


More information about the llvm-bugs mailing list