p4c icon indicating copy to clipboard operation
p4c copied to clipboard

Add additional optimizations to `SimplifySelectCases` midend pass

Open kfcripps opened this issue 4 months ago • 0 comments

Reduces the following parser code:

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

to:

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

and reduces the following parser code:

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

to:

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

kfcripps avatar Sep 03 '25 23:09 kfcripps