We can reuse the folding of REAL.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I was wondering why similar intrinsics SNGL and FLOAT work already but they seem to be lowered earlier to REAL, does this make sense?
(Also this is my first patch for flang, so if I'm missing something very obvious please let me know. Thanks!)
Thanks for the patch.
I was wondering why similar intrinsics SNGL and FLOAT work already but they seem to be lowered earlier to REAL, does this make sense?
Yes, SNGL is a specific intrinsic (defined in section 16.8 in Fortran 2018 standard), while DBLE is a generic intrinsic (defined in section 16.9). Intrinsic procedure call resolution (Probe in lib/Evaluate/intrinsics.cpp) replaces specific names by the related generic names. So SGNL is replaced by REAL there, but DBLE is not. So your patch in folding makes sense to me.
flang/test/Evaluate/fold-dble.f90 | ||
---|---|---|
8 | test_folding.py is testing that parameters names text_xxx (with xxx being any string) folds to .true.. Your test currently checks that dble is folded, but not that it is folded correctly. To make your test more thorough, you could add to the module definitions: logical, parameter :: test_dble_1 = ntotal_f == real(nx*ny*nz, kind(0.0D0)) logical, parameter :: test_dble_2 = kind(dble(nx)) == kind(0.0D0) |
Yes, SNGL is a specific intrinsic (defined in section 16.8 in Fortran 2018 standard), while DBLE is a generic intrinsic (defined in section 16.9). Intrinsic procedure call resolution (Probe in lib/Evaluate/intrinsics.cpp) replaces specific names by the related generic names. So SGNL is replaced by REAL there, but DBLE is not. So your patch in folding makes sense to me.
OK. Thanks a lot for the clarification, @jeanPerier.
test_folding.py is testing that parameters names text_xxx (with xxx being any string) folds to .true.. Your test currently checks that dble is folded, but not that it is folded correctly. To make your test more thorough, you could add to the module definitions: