@@ -75,12 +75,7 @@ class ReplaceIntrinsicFunctions: public ASR::BaseExprReplacer<ReplaceIntrinsicFu
75
75
}
76
76
ASR::expr_t * current_expr_ = instantiate_function (al, x->base .base .loc ,
77
77
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_;
84
79
}
85
80
86
81
void replace_IntrinsicArrayFunction (ASR::IntrinsicArrayFunction_t* x) {
@@ -120,12 +115,7 @@ class ReplaceIntrinsicFunctions: public ASR::BaseExprReplacer<ReplaceIntrinsicFu
120
115
ASR::expr_t * current_expr_ = instantiate_function (al, x->base .base .loc ,
121
116
global_scope, arg_types, x->m_type , new_args, x->m_overload_id );
122
117
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_;
129
119
if (ASR::is_a<ASR::FunctionCall_t>(*func_call)) {
130
120
ASR::symbol_t *call_sym = ASRUtils::symbol_get_past_external (
131
121
ASR::down_cast<ASR::FunctionCall_t>(func_call)->m_name );
@@ -287,7 +277,7 @@ class ReplaceFunctionCallReturningArray: public ASR::BaseExprReplacer<ReplaceFun
287
277
ASR::expr_t * result_var_ = nullptr ;
288
278
int dim_index = ASRUtils::IntrinsicArrayFunctionRegistry::
289
279
get_dim_index (func2intrinsicid[x_m_name]);
290
- if ( dim_index != - 1 ) {
280
+ if ( dim_index == 1 ) {
291
281
ASR::expr_t * dim = x->m_args [dim_index].m_value ;
292
282
if ( !ASRUtils::is_value_constant (ASRUtils::expr_value (dim)) ) {
293
283
// Possibly can be replaced by calling "get_result_var_for_runtime_dim"
@@ -302,6 +292,12 @@ class ReplaceFunctionCallReturningArray: public ASR::BaseExprReplacer<ReplaceFun
302
292
throw LCompilersException (" Constant dimension cannot be extracted." );
303
293
}
304
294
}
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 );
305
301
}
306
302
result_counter += 1 ;
307
303
ASR::call_arg_t new_arg;
@@ -366,15 +362,6 @@ class ReplaceFunctionCallReturningArrayVisitor : public ASR::CallReplacerOnExpre
366
362
pass_result.n = 0 ;
367
363
}
368
364
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
-
378
365
};
379
366
380
367
void pass_replace_intrinsic_function (Allocator &al, ASR::TranslationUnit_t &unit,
0 commit comments