Skip to content

Conversation

@ceseo
Copy link
Contributor

@ceseo ceseo commented Nov 14, 2025

Modify the TypeCategory for quad-precision COMPLEX to CFI_type_float128_Complex so it matches the TypeCode returned by SELECT TYPE lowering.

Fixes #134565

Modify the TypeCategory for quad-precision COMPLEX to
CFI_type_float128_Complex so it matches the TypeCode returned by
SELECT TYPE lowering.

Fixes llvm#134565
@ceseo
Copy link
Contributor Author

ceseo commented Nov 14, 2025

I'd like to add a testcase (check the generated LLVM IR for the correct type selection). Where's the best place to put it?

@ceseo ceseo requested a review from jeanPerier November 18, 2025 14:50
@jeanPerier
Copy link
Contributor

I'd like to add a testcase (check the generated LLVM IR for the correct type selection). Where's the best place to put it?

You could add a test like this using a fir.box<cpmlx.complex<f128>> type instead of the derived type. The resulting descriptor structure should contain the type code value.

@ceseo
Copy link
Contributor Author

ceseo commented Nov 19, 2025

You could add a test like this using a fir.box<cpmlx.complex<f128>> type instead of the derived type. The resulting descriptor structure should contain the type code value.

My question was more in the lines of where in the directory structure is more adequate. Although the fix is in flang-rt, this is technically lowering. Maybe flang/test/Lower?

@jeanPerier
Copy link
Contributor

You could add a test like this using a fir.box<cpmlx.complex<f128>> type instead of the derived type. The resulting descriptor structure should contain the type code value.

My question was more in the lines of where in the directory structure is more adequate. Although the fix is in flang-rt, this is technically lowering. Maybe flang/test/Lower?

Ah sorry, so you want to test SELECT TYPE lowering?

If so, I think you should make a small FIR test using fir.select_type with complex and check that you get the code you expect.

See https://github.com/llvm/llvm-project/blob/main/flang/test/Lower/select-type-2.fir as an example (except these kinds of test should live in flang/test/Fir).

You can generate your input from Fortran with bbc -emit-fir, but try to keep the input very small, focused on the testing the resulting code.

@ceseo
Copy link
Contributor Author

ceseo commented Nov 19, 2025

You can generate your input from Fortran with bbc -emit-fir, but try to keep the input very small, focused on the testing the resulting code.

Actually, scratch that. The resulting IR will be the same with or without the fix (it will branch differently if the type is 16 or 17). I added a runtime check as you mentioned earlier.

If you think it's OK, I'll merge this.

@github-actions
Copy link

🐧 Linux x64 Test Results

  • 255 tests passed
  • 1 test skipped

Copy link
Contributor

@jeanPerier jeanPerier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ceseo ceseo merged commit a9a14d6 into llvm:main Nov 20, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Flang] Quadruple precision COMPLEX used in TYPE IS statement in SELECT TYPE construct is not executed correctly

2 participants