[all-commits] [llvm/llvm-project] ccd314: [OpenMP][OMPIRBuilder] Add generation of SIMD alig...

Dominik Adamski via All-commits all-commits at lists.llvm.org
Tue Oct 18 00:17:16 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ccd314d3209a192fc17ad621cf7fe3f09f7c7b9f
      https://github.com/llvm/llvm-project/commit/ccd314d3209a192fc17ad621cf7fe3f09f7c7b9f
  Author: Dominik Adamski <dominik.adamski at amd.com>
  Date:   2022-10-18 (Tue, 18 Oct 2022)

  Changed paths:
    M clang/lib/CodeGen/CGStmtOpenMP.cpp
    A clang/test/OpenMP/irbuilder_simd_aligned.cpp
    M llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
    M llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
    M llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
    M mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

  Log Message:
  -----------
  [OpenMP][OMPIRBuilder] Add generation of SIMD align assumptions to OMPIRBuilder

Currently generation of align assumptions for OpenMP simd construct is done
outside OMPIRBuilder for C code and it is not supported for Fortran.

According to OpenMP 5.0 standard (2.9.3) only pointers and arrays can be
aligned for C code.

If given aligned variable is pointer, then Clang generates the following set
of the LLVM IR isntructions to support simd align clause:

; memory allocation for pointer address:
%A.addr = alloca ptr, align 8
; some LLVM IR code
; Alignment instructions (alignment is equal to 32):
%0 = load ptr, ptr %A.addr, align 8
call void @llvm.assume(i1 true) [ "align"(ptr %0, i64 32) ]

If given aligned variable is array, then Clang generates the following set
of the LLVM IR isntructions to support simd align clause:

; memory allocation for array:
%B = alloca [10 x i32], align 16
; some LLVM IR code
; Alignment instructions (alignment is equal to 32):
%arraydecay = getelementptr inbounds [10 x i32], ptr %B, i64 0, i64 0
call void @llvm.assume(i1 true) [ "align"(ptr %arraydecay, i64 32) ]

OMPIRBuilder was modified to generate aligned assumptions. It generates only
llvm.assume calls. Frontend is responsible for generation of aligned pointer
and getting the default alignment value if user does not specify it in aligned
clause.

Unit and regression tests were added to check if aligned clause was handled correctly.

Differential Revision: https://reviews.llvm.org/D133578

Reviewed By: jdoerfert




More information about the All-commits mailing list