Skip to content

Add promoted const_args to --fold-constant PASS#157

Merged
YanzhouTang merged 5 commits intocoredac:mainfrom
YanzhouTang:fold_args_const
Oct 20, 2025
Merged

Add promoted const_args to --fold-constant PASS#157
YanzhouTang merged 5 commits intocoredac:mainfrom
YanzhouTang:fold_args_const

Conversation

@YanzhouTang
Copy link
Copy Markdown
Collaborator

As we discussed in Issue #152 , after args being promoted to constant, they are not folded in the next --fold-constant PASS.

This PR add this feature based on simple_loop case.

  1. neura.gep: its left operand represents base_pointer, we fold this operand if it is a constant.
  2. neura.store: its right operand represents destination address, we fold this operand if it is a constant.

After leveraging --promote-func-arg-to-const and --fold-constant, the final operations are reduced to 20, and II = 5 (equals to RecII = 5)

@tancheng
Copy link
Copy Markdown
Contributor

the final operations are reduced to 20, and II = 5 (equals to RecII = 5)

What is the original #ops and II?

@YanzhouTang
Copy link
Copy Markdown
Collaborator Author

the final operations are reduced to 20, and II = 5 (equals to RecII = 5)

What is the original #ops and II?

Original ops are 33, and original II = 7

@tancheng
Copy link
Copy Markdown
Contributor

tancheng commented Oct 16, 2025

the final operations are reduced to 20, and II = 5 (equals to RecII = 5)

What is the original #ops and II?

Original ops are 33, and original II = 7

Cool, then next step is https://github.com/coredac/dataflow/blob/main/test/neura/for_loop/relu_test.mlir, IIRC, its II is 11, let's see whether ur optimization can help it, plz try before and after ur optimization on this test, and include // CHECK the updated II in this test. And we will optimize it further with other optimization if necessary.

After above done, let's move to your complex kernel.

@tancheng
Copy link
Copy Markdown
Contributor

@YanzhouTang any blocker~?

@YanzhouTang
Copy link
Copy Markdown
Collaborator Author

@YanzhouTang any blocker~?

Sorry I'm busy with some school matters ddl yesterday. 😭 I've updated a version that rename the lhs_value and rhs_value, as well as test.mlir. I'll go on relu kernel optimization today.

@tancheng
Copy link
Copy Markdown
Contributor

Why the Github Action stops... Any idea?

@YanzhouTang
Copy link
Copy Markdown
Collaborator Author

YanzhouTang commented Oct 20, 2025

Why the Github Action stops... Any idea?

I found some testcases failed due to renaming in my local version. I'm fixing these cases one by one and I'll make a new commit after all tetscase clean

@tancheng tancheng linked an issue Oct 20, 2025 that may be closed by this pull request
@YanzhouTang YanzhouTang merged commit 7a836fe into coredac:main Oct 20, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P0] Potential redundent oprations optimization

2 participants