This is an archive of the discontinued LLVM Phabricator instance.

[fir] Add fir.cmpc conversion
ClosedPublic

Authored by rovka on Nov 16 2021, 2:29 AM.

Details

Summary

This patch adds the codegen for fir.cmpc. The real and imaginary parts
are extracted and compared separately. For the .EQ. predicate the
results are AND'd, for the .NE. predicate the results are OR'd, and for
other predicates we keep only the result on the real parts.

This patch is part of the upstreaming effort from fir-dev.

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>

Diff Detail

Event Timeline

rovka created this revision.Nov 16 2021, 2:29 AM
rovka requested review of this revision.Nov 16 2021, 2:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 16 2021, 2:29 AM
rovka added inline comments.Nov 16 2021, 2:31 AM
flang/lib/Optimizer/CodeGen/CodeGen.cpp
503

I modified this to use getComplexEleTy instead of reconstructing it. Hope it's fine.

flang/lib/Optimizer/CodeGen/CodeGen.cpp
503

The previous code kind of assumes the complex types are of FIR type. The new code accommodates both (FIR and mlir complex).

If the conversion supports both then we should have a test for mlir complex as well.

rovka updated this revision to Diff 387545.Nov 16 2021, 2:47 AM

Fix rebase mishap

rovka added inline comments.Nov 16 2021, 2:50 AM
flang/lib/Optimizer/CodeGen/CodeGen.cpp
503

I don't think we can get past parsing or other things with a MLIR complex (FIROps.td says the inputs to cmpc are fir_ComplexType). So we'll never take that branch in getComplexEleTy.

LGTM.
I have this conversion in the Flang tutorial.

This revision is now accepted and ready to land.Nov 16 2021, 3:17 AM
This revision was automatically updated to reflect the committed changes.