@@ -75,12 +75,7 @@ class ReplaceIntrinsicFunctions: public ASR::BaseExprReplacer<ReplaceIntrinsicFu
7575 }
7676 ASR::expr_t * current_expr_ = instantiate_function (al, x->base .base .loc ,
7777 global_scope, arg_types, x->m_type , new_args, x->m_overload_id );
78- if ( ASR::is_a<ASR::ArrayPhysicalCast_t>(*(*current_expr)) ) {
79- ASR::ArrayPhysicalCast_t* array_physical_cast_t = ASR::down_cast<ASR::ArrayPhysicalCast_t>(*current_expr);
80- array_physical_cast_t ->m_arg = current_expr_;
81- } else {
82- *current_expr = current_expr_;
83- }
78+ *current_expr = current_expr_;
8479 }
8580
8681 void replace_IntrinsicArrayFunction (ASR::IntrinsicArrayFunction_t* x) {
@@ -120,12 +115,7 @@ class ReplaceIntrinsicFunctions: public ASR::BaseExprReplacer<ReplaceIntrinsicFu
120115 ASR::expr_t * current_expr_ = instantiate_function (al, x->base .base .loc ,
121116 global_scope, arg_types, x->m_type , new_args, x->m_overload_id );
122117 ASR::expr_t * func_call = current_expr_;
123- if ( ASR::is_a<ASR::ArrayPhysicalCast_t>(*(*current_expr)) ) {
124- ASR::ArrayPhysicalCast_t* array_physical_cast_t = ASR::down_cast<ASR::ArrayPhysicalCast_t>(*current_expr);
125- array_physical_cast_t ->m_arg = current_expr_;
126- } else {
127- *current_expr = current_expr_;
128- }
118+ *current_expr = current_expr_;
129119 if (ASR::is_a<ASR::FunctionCall_t>(*func_call)) {
130120 ASR::symbol_t *call_sym = ASRUtils::symbol_get_past_external (
131121 ASR::down_cast<ASR::FunctionCall_t>(func_call)->m_name );
@@ -287,7 +277,7 @@ class ReplaceFunctionCallReturningArray: public ASR::BaseExprReplacer<ReplaceFun
287277 ASR::expr_t * result_var_ = nullptr ;
288278 int dim_index = ASRUtils::IntrinsicArrayFunctionRegistry::
289279 get_dim_index (func2intrinsicid[x_m_name]);
290- if ( dim_index != - 1 ) {
280+ if ( dim_index == 1 ) {
291281 ASR::expr_t * dim = x->m_args [dim_index].m_value ;
292282 if ( !ASRUtils::is_value_constant (ASRUtils::expr_value (dim)) ) {
293283 // Possibly can be replaced by calling "get_result_var_for_runtime_dim"
@@ -302,6 +292,12 @@ class ReplaceFunctionCallReturningArray: public ASR::BaseExprReplacer<ReplaceFun
302292 throw LCompilersException (" Constant dimension cannot be extracted." );
303293 }
304294 }
295+ } else if ( dim_index == 2 ) {
296+ result_var_ = PassUtils::create_var (result_counter,
297+ std::string (ASRUtils::symbol_name (x->m_name )) + " _res" ,
298+ x->base .base .loc , x->m_type , al, current_scope);
299+ } else {
300+ LCOMPILERS_ASSERT (false );
305301 }
306302 result_counter += 1 ;
307303 ASR::call_arg_t new_arg;
@@ -366,15 +362,6 @@ class ReplaceFunctionCallReturningArrayVisitor : public ASR::CallReplacerOnExpre
366362 pass_result.n = 0 ;
367363 }
368364
369- void visit_Assignment (const ASR::Assignment_t& x) {
370- ASR::CallReplacerOnExpressionsVisitor<
371- ReplaceFunctionCallReturningArrayVisitor>::visit_Assignment (x);
372- ASR::Assignment_t& xx = const_cast <ASR::Assignment_t&>(x);
373- if ( ASR::is_a<ASR::ArrayPhysicalCast_t>(*x.m_value ) ) {
374- xx.m_value = ASR::down_cast<ASR::ArrayPhysicalCast_t>(x.m_value )->m_arg ;
375- }
376- }
377-
378365};
379366
380367void pass_replace_intrinsic_function (Allocator &al, ASR::TranslationUnit_t &unit,
0 commit comments