[clang] [flang] [flang] Add UNSIGNED (PR #113504)
Peter Klausler via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 25 08:02:05 PDT 2024
================
@@ -968,21 +968,41 @@ struct BinaryOp {};
fir::FirOpBuilder &builder, \
const Op &, hlfir::Entity lhs, \
hlfir::Entity rhs) { \
- return hlfir::EntityWithAttributes{ \
- builder.create<GenBinFirOp>(loc, lhs, rhs)}; \
+ if constexpr (Fortran::common::TypeCategory::GenBinTyCat == \
+ Fortran::common::TypeCategory::Unsigned && \
+ !std::is_same_v<GenBinFirOp, mlir::arith::DivUIOp>) { \
+ int bits = \
+ Fortran::evaluate::Type<Fortran::common::TypeCategory::Integer, \
+ KIND>::Scalar::bits; \
+ auto signlessType = mlir::IntegerType::get( \
+ builder.getContext(), bits, \
+ mlir::IntegerType::SignednessSemantics::Signless); \
+ auto lhsSL = builder.createConvert(loc, signlessType, lhs); \
----------------
klausler wrote:
The conversions are gone from the llvm output so at least there aren't no-op copies in the generated code.
When/if clang emits mlir, any missing/broken unsigned optimizations will be more prominent and likely to get fixed for us.
https://github.com/llvm/llvm-project/pull/113504
More information about the cfe-commits
mailing list