Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSA pass producing unnecessary phi nodes #28

Open
rdaly525 opened this issue Jan 6, 2020 · 4 comments
Open

SSA pass producing unnecessary phi nodes #28

rdaly525 opened this issue Jan 6, 2020 · 4 comments
Assignees

Comments

@rdaly525
Copy link
Collaborator

rdaly525 commented Jan 6, 2020

The following example will produce a phi node for 'a' even thought it is unneeded. This causes problems when the types of 'a' in each branch are different

def foo(pred : Bit, x : BitVector[16]):
    if pred:
        a = Signed[16](x)
        b = a > 0
    else:
        a = Unsigned[16](x)
        b = a > 0
    #code that never uses 'a' again

@cdonovick
Copy link
Collaborator

If a is never used again I would immagine dead code elimination in the rtl compiler would optimize this away. Is there evidence that this effect QOR?

@rdaly525
Copy link
Collaborator Author

rdaly525 commented Jan 7, 2020

The problem is when 'a' is a different type in each branch. The extraneous phi node causes type errors.

@cdonovick
Copy link
Collaborator

Ahh I see. While possible, this is actually quite annoying to fix. Could we work around this for now?

@rdaly525
Copy link
Collaborator Author

rdaly525 commented Jan 7, 2020

@leonardt, it seems that magma handles this case without erroring. Is there a way to leverage what you have written?

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

No branches or pull requests

2 participants