This is an archive of the discontinued LLVM Phabricator instance.

[fir] Add fir.zero_bits conversion pattern to LLVM IR dialect
ClosedPublic

Authored by clementval on Nov 2 2021, 6:50 AM.

Details

Summary

This patch adds the ZeroOpConversion pattern to LLVM IR dialect.
Conversion of aggregate types is not implemented yet and will trigger a
failure to legalize the operation. This is tested in the
convert-to-llvm-invalid.fir test file.

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

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

Diff Detail

Event Timeline

clementval created this revision.Nov 2 2021, 6:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 2 2021, 6:50 AM
Herald added a subscriber: mehdi_amini. · View Herald Transcript
clementval requested review of this revision.Nov 2 2021, 6:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 2 2021, 6:50 AM
flang/test/Fir/convert-to-llvm.fir
121

What about f80 and f24?

129

Missed f64.

clementval updated this revision to Diff 384088.Nov 2 2021, 7:07 AM

Add missing float tests

clementval marked 2 inline comments as done.Nov 2 2021, 7:08 AM
clementval added inline comments.
flang/test/Fir/convert-to-llvm.fir
121

Added bf16 and f80.

129

Thanks for catching this. This is fixed.

clementval edited the summary of this revision. (Show Details)Nov 2 2021, 7:08 AM
clementval updated this revision to Diff 384090.Nov 2 2021, 7:10 AM
clementval marked 2 inline comments as done.

Remove unused loc variable

kiranchandramohan accepted this revision.Nov 2 2021, 8:22 AM

LGTM.

Nit: Do we need a TODO for array types?

This revision is now accepted and ready to land.Nov 2 2021, 8:22 AM

LGTM.

Nit: Do we need a TODO for array types?

Thanks Kiran. Added array in the TODO before landing.

mehdi_amini added inline comments.Nov 2 2021, 4:26 PM
flang/lib/Optimizer/CodeGen/CodeGen.cpp
188

Nit: in general Patterns aren't supposed to emit errors directly but to wrap the message in notifyFailure(...).

The conversion may still succeed if another pattern ends up folding this op (or matching it), so having an error can be confusing.

In general if we want end-use diagnostic, it is best to use other mechanism (like using the partial conversion which has an extra argument for collecting "unconvertedOps").

clementval added inline comments.Nov 3 2021, 12:35 AM
flang/lib/Optimizer/CodeGen/CodeGen.cpp
188

Ok I'll update that.

clementval marked an inline comment as done.Nov 3 2021, 2:37 AM
clementval added inline comments.
flang/lib/Optimizer/CodeGen/CodeGen.cpp
188

Done in D113091