[flang-commits] [flang] [Flang] Make handling of %VAL consistent with gfortran (PR #157873)
via flang-commits
flang-commits at lists.llvm.org
Wed Sep 10 08:29:21 PDT 2025
https://github.com/jeanPerier commented:
Thanks, I think this is the right direction.
Since there is actually no code generation between fir.logical to fir.ref and vice versa, I think it would make sense to change the `isIntegerCompatible` [here](https://github.com/llvm/llvm-project/blob/ad80f736312c73c51501bf26ca9d2d0569b8a8c0/flang/lib/Optimizer/Dialect/FIROps.cpp#L1525C3-L1526C74) in `fir::ConvertOp::canBeConverted` to `isInteger`.
That way fir.convert between logical and pointer types will not be allowed and the code above will trigger the signature conversion. Except for integers, this is already what is happening with %VAL mismatch.
For the integer types, there is an intptr conversion that is inserted, which is admittedly slightly different than a function cast since it will zero out the upper register bits depending on the while they would be undefined with a function cast. I think this behavior is OK (zero is an acceptable value for something undefined) and is better to keep a single simple loop than to add more logic.
https://github.com/llvm/llvm-project/pull/157873
More information about the flang-commits
mailing list