Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add additional optimizations to SimplifySelectCases midend pass#5372

Draft
kfcripps wants to merge 2 commits intop4lang:mainfrom
kfcripps:simplify-select-cases
Draft

Add additional optimizations to SimplifySelectCases midend pass#5372
kfcripps wants to merge 2 commits intop4lang:mainfrom
kfcripps:simplify-select-cases

Conversation

Copy link
Contributor

kfcripps commented Sep 3, 2025 *
edited
Loading

Reduces the following parser code:

state state_1 {
transition select(packet.lookahead>()) {
0x21 : state_3;
0x21 : state_2;
default : accept;
}
}

to:

state state_1 {
transition select(packet.lookahead>()) {
0x21 : state_3;
default : accept;
}
}

and reduces the following parser code:

state state_1 {
transition select(packet.lookahead>()) {
0x21 : state_3;
0x22 : state_2;
default : state_3;
}
}

to:

state state_1 {
transition select(packet.lookahead>()) {
0x22 : state_2;
default : state_3;
}
}

kfcripps added the core Topics concerning the core segments of the compiler (frontend, midend, parser) label Sep 3, 2025
kfcripps requested review from ChrisDodd and oleg-ran-amd September 3, 2025 23:56
kfcripps marked this pull request as draft September 4, 2025 12:24
kfcripps force-pushed the simplify-select-cases branch from 465a4ce to 6aaa0e4 Compare September 17, 2025 23:39
kfcripps added 2 commits November 18, 2025 17:03
Signed-off-by: kfcripps
Signed-off-by: Kyle Cripps
kfcripps force-pushed the simplify-select-cases branch from 6aaa0e4 to 902b6c2 Compare November 19, 2025 01:03
ChrisDodd approved these changes Nov 19, 2025

bool isCompileTimeConstant(const IR::Expression *expr, const TypeMap *typeMap) {
if (expr->is()) return true;
if (expr->is()) return true;
Copy link
Contributor

ChrisDodd Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be checking for an actual constant, not a compile-time constant (compile-time constants also include directionless parameters that will be bound to a constant in an instantiation), so seems misnamed. perhaps just isConstant?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

ChrisDodd ChrisDodd approved these changes

oleg-ran-amd Awaiting requested review from oleg-ran-amd

Assignees

No one assigned

Labels

core Topics concerning the core segments of the compiler (frontend, midend, parser)

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants