Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flang2] Generate loads of complex variables with correct alignment #1449

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions test/llvm_ir_correct/load-alignment.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
! Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
! See https://llvm.org/LICENSE.txt for license information.
! SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

! Check that load instructions are emitted with correct alignment.

! RUN: %flang -S -emit-flang-llvm %s -o %t.ll
! RUN: FileCheck %s < %t.ll

! CHECK: load i8, ptr %in1, align 1
function bpass(in1)
logical(kind=1) :: in1, bpass
bpass = in1
end function bpass

! CHECK: load i32, ptr %in1, align 4
function ipass(in1)
integer(kind=4) :: in1, ipass
ipass = in1
end function ipass

! CHECK: load i64, ptr %in1, align 8
function lpass(in1)
integer(kind=8) :: in1, lpass
lpass = in1
end function lpass

! CHECK: load float, ptr %in1, align 4
function fpass(in1)
real(kind=4) :: in1, fpass
fpass = in1
end function fpass

! CHECK: load double, ptr %in1, align 8
function dpass(in1)
real(kind=8) :: in1, dpass
dpass = in1
end function dpass

! CHECK: load <{float, float}>, ptr %in1, align 8
function cfpass(in1)
complex(kind=4) :: in1, cfpass
cfpass = in1
end function cfpass

! CHECK: load <{double, double}>, ptr %in1, align 16
function cdpass(in1)
complex(kind=8) :: in1, cdpass
cdpass = in1
end function cdpass
7 changes: 2 additions & 5 deletions tools/flang2/flang2exe/cgmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8572,15 +8572,12 @@ gen_llvm_expr(int ilix, LL_Type *expected_type)
ld_ili = ILI_OPND(ilix, 1);
nme_ili = ILI_OPND(ilix, 2);
msz = (MSZ)ILI_OPND(ilix, 3);
flags = opc == IL_LDSCMPLX ? DT_CMPLX
#ifdef TARGET_SUPPORTS_QUADFP
: opc == IL_LDQCMPLX ? DT_QCMPLX
#endif
: DT_DCMPLX;
operand = gen_address_operand(ld_ili, nme_ili, false,
make_ptr_lltype(expected_type), (MSZ)-1);
assert(operand->ll_type->data_type == LL_PTR,
"Invalid operand for cmplx load", ilix, ERR_Fatal);
flags =
ldst_instr_flags_from_dtype_nme(msz_dtype(msz), nme_ili);
operand =
make_load(ilix, operand, operand->ll_type->sub_types[0], msz, flags);
} break;
Expand Down
Loading