Skip to content

Commit 55a4534

Browse files
Fix ICE in ArithmeticIF for INT*8 type
When half precision reals were introduced the table (aif) used in the ILI codegen for ArithmeticIF was increased in size and the offset for INT*8 increased by one. But the entry for half precision was not inserted, this causes an ICE for INT*8 type. The fix is to introduce the entry for the half precision type before the INT*8 type.
1 parent 31e549d commit 55a4534

File tree

6 files changed

+73
-0
lines changed

6 files changed

+73
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#
2+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3+
# See https://llvm.org/LICENSE.txt for license information.
4+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
#
6+
7+
$(TEST): run
8+
9+
10+
build: $(SRC)/$(TEST).f90
11+
-$(RM) $(TEST).$(EXESUFFIX) core *.d *.mod FOR*.DAT FTN* ftn* fort.*
12+
@echo ------------------------------------ building test $@
13+
-$(CC) -c $(CFLAGS) $(SRC)/check.c -o check.$(OBJX)
14+
-$(FC) -c $(FFLAGS) $(LDFLAGS) $(SRC)/$(TEST).f90 -o $(TEST).$(OBJX)
15+
-$(FC) $(FFLAGS) $(LDFLAGS) $(TEST).$(OBJX) check.$(OBJX) $(LIBS) -o $(TEST).$(EXESUFFIX)
16+
-$(FC) -c -i8 $(FFLAGS) $(LDFLAGS) $(SRC)/$(TEST).f90 -o $(TEST).$(OBJX).i8
17+
-$(FC) $(FFLAGS) $(LDFLAGS) $(TEST).$(OBJX).i8 check.$(OBJX) $(LIBS) -o $(TEST).$(EXESUFFIX).i8
18+
19+
20+
run:
21+
@echo ------------------------------------ executing test $(TEST)
22+
$(TEST).$(EXESUFFIX)
23+
$(TEST).$(EXESUFFIX).i8
24+
25+
verify: ;
26+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#
2+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3+
# See https://llvm.org/LICENSE.txt for license information.
4+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
6+
# Shared lit script for each tests. Run bash commands that run tests with make.
7+
8+
# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t
9+
# RUN: cat %t | FileCheck %S/runmake
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
!
2+
! Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3+
! See https://llvm.org/LICENSE.txt for license information.
4+
! SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
6+
! tests arithmetic if codegen
7+
8+
function aif(x, expect)
9+
integer :: x
10+
integer :: expect(3)
11+
integer :: res
12+
if(x) 5,15,25
13+
5 res = expect(1)
14+
goto 35
15+
15 res = expect(2)
16+
goto 35
17+
25 res = expect(3)
18+
35 aif = res
19+
end function
20+
21+
program main
22+
integer, parameter :: val1=10
23+
integer, parameter :: val2=20
24+
integer, parameter :: val3=30
25+
integer :: res(3)
26+
integer :: expect(3) = (/10,20,30/)
27+
res(1) = aif(-1, expect)
28+
res(2) = aif(0, expect)
29+
res(3) = aif(1, expect)
30+
call check(res, expect, 3)
31+
end program

tools/flang2/flang2exe/exp_ftn.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3416,6 +3416,8 @@ exp_bran(ILM_OP opc, ILM *ilmp, int curilm)
34163416
IL_FCJMP, MSZ_F4},
34173417
{IL_DCJMPZ, IL_CSEDP, DT_DBLE, IL_STDP, IL_LDDP, IL_DCMPZ, IL_DSUB,
34183418
IL_DCJMP, MSZ_F8},
3419+
{IL_HFCJMPZ, IL_CSEHP, DT_HALF, IL_STHP, IL_LDHP, IL_HFCMPZ, IL_HFSUB,
3420+
IL_HFCJMP, MSZ_F2},
34193421
{IL_KCJMPZ, IL_CSEKR, DT_INT8, IL_STKR, IL_LDKR, IL_KCMPZ, IL_KSUB,
34203422
IL_KCJMP, MSZ_I8},
34213423
};
@@ -3452,6 +3454,9 @@ exp_bran(ILM_OP opc, ILM *ilmp, int curilm)
34523454
goto comaif;
34533455
case IM_DAIF: /* double arithmetic IF */
34543456
type = 2;
3457+
goto comaif;
3458+
case IM_HFAIF: /* half precision arithmetic IF */
3459+
type = 3;
34553460
comaif:
34563461
/* arithmetic if processing */
34573462
ilix = ILM_RESULT(ILM_OPND(ilmp, 1));

tools/flang2/flang2exe/ili.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ inline MSZ MSZ_ILI_OPND(int i, int opn) {
427427
/* Synonyms (beware conflicting case values) */
428428
#define MSZ_WORD MSZ_SWORD
429429
#define MSZ_BYTE MSZ_UBYTE
430+
#define MSZ_F2 MSZ_FHALF
430431
#define MSZ_F4 MSZ_FWORD
431432
#define MSZ_F8 MSZ_FLWORD
432433
#define MSZ_DBLE MSZ_FLWORD

tools/shared/atomic_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ typedef enum MSZ {
2121
MSZ_SHWORD = 0x01, /* signed 16-bit short */
2222
MSZ_UBYTE = 0x04, /* unsigned byte */
2323
MSZ_UHWORD = 0x05, /* unsigned 16-bit short */
24+
MSZ_FHALF = 0x09, /* 16-bit half precision float */
2425

2526
/* Codes for types larger than two bytes. These are all distinct values
2627
* suitable for use as case labels in switches. The holes in this sequence

0 commit comments

Comments
 (0)