Giter Club home page Giter Club logo

Comments (5)

kfcripps avatar kfcripps commented on June 26, 2024

This was also introduced by e60cb8a. :)

from p4c.

kfcripps avatar kfcripps commented on June 26, 2024

Actions inlining transforms foo() to something like this:

    @name("foo") action foo_0() {
        {
            @name("x") bit<28> x_0;
            @name("y") bit<28> y_0;
            if (true) {
                if (false) {
                    __e(x_0);
                }
            } else if (false) {
                __e2(y_0);
            }
        }
    }

The problem is similar to #4500.

The condition for both "if (false)" IR::IfStatements point to the same IR::BoolLiteral, which is not expected by SimplifyDefUse.

I was able to fix this with the following change to SubstituteParameters::postorder(IR::PathExpression *expr):

...
        auto value = subst->lookup(param)->expression->clone();
...

from p4c.

kfcripps avatar kfcripps commented on June 26, 2024

I was able to fix this with the following change to SubstituteParameters::postorder(IR::PathExpression *expr):

I am not sure if it would better to perform the cloning here or in ActionsInliner::preorder(IR::MethodCallStatement *statement) instead.

from p4c.

kfcripps avatar kfcripps commented on June 26, 2024

Here is another case, which hits the same Compiler bug, but is not fixed by my change described above:

extern void __e(in bit<28> arg);
extern void __e2(in bit<28> arg);

control C() {
    action bar(bool a, bool b) {
        bit<28> x; bit<28> y;
        if (a) {
            if (b) {
                __e(x);
            }
        } else {
            if (b) {
                __e2(y);
            }
        }
    }

    action baz() {
        bar(true, false);
    }

    action foo() {
        baz();
        baz();
    }

    table t {
        actions = { foo; }
        default_action = foo;
    }

    apply {
        t.apply();
    }
}

control proto();
package top(proto p);

top(C()) main;

from p4c.

kfcripps avatar kfcripps commented on June 26, 2024

or by inserting a pass that converts DAGs into trees before the def-use analysis.

This is starting to sound like the best solution..

from p4c.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.