[flang-commits] [flang] [flang] Fix bogus error about procedure incompatbility (PR #107645)
via flang-commits
flang-commits at lists.llvm.org
Mon Sep 9 09:24:27 PDT 2024
================
@@ -1088,24 +1088,42 @@ Expr<T> FoldMINorMAX(
static_assert(T::category == TypeCategory::Integer ||
T::category == TypeCategory::Real ||
T::category == TypeCategory::Character);
- std::vector<Constant<T> *> constantArgs;
- // Call Folding on all arguments, even if some are not constant,
- // to make operand promotion explicit.
- for (auto &arg : funcRef.arguments()) {
- if (auto *cst{Folder<T>{context}.Folding(arg)}) {
- constantArgs.push_back(cst);
+ auto &args{funcRef.arguments()};
+ bool ok{true};
+ std::optional<Expr<T>> result;
+ Folder<T> folder{context};
+ for (std::optional<ActualArgument> &arg : args) {
+ // Call Folding on all arguments to make operand promotion explicit.
+ if (!folder.Folding(arg)) {
+ // TODO: Lowering can't handle having every FunctionRef for max and min
+ // being converted into Extremum<T>. That needs fixing. Until that
----------------
jeanPerier wrote:
Do you have sources for such cases. I wonder if this has to do with the handling of optional arguments to min/max that is not done for Extremum<T>.
I am not sure the folding here would properly deal with such optional arguments anyway since `max(a,b,c)` is not equivalent to `max(max(a,b), c)` as far as optionals are concerned.
Extremum<T> for characters is also [unimplemented](https://github.com/llvm/llvm-project/blob/db6051dae085c35020c1273ae8d38508c9958bc7/flang/lib/Lower/ConvertExprToHLFIR.cpp#L1046) since it was not easily testable so far.
Otherwise, unconditional folding for numerical with two arguments should "just work", and it is indeed a bug if it does not.
https://github.com/llvm/llvm-project/pull/107645
More information about the flang-commits
mailing list