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

for loop incorrectly transformed by p4c #4739

Open
jafingerhut opened this issue Jun 22, 2024 · 2 comments
Open

for loop incorrectly transformed by p4c #4739

jafingerhut opened this issue Jun 22, 2024 · 2 comments
Assignees
Labels
bug This behavior is unintended and should be fixed. core Topics concerning the core segments of the compiler (frontend, midend, parser)

Comments

@jafingerhut
Copy link
Contributor

jafingerhut commented Jun 22, 2024

I was writing some simple test cases of for loops to try out some aspects of this feature, and believe I have found a case where the compiler front end in some pass has an incorrect transformation, because the output of the front end, and thus also the mid end, appear functionally to be infinite loops, whereas the input program was definitely not.

I tested with two versions of p4c, the most recent of which was:

  • p4c git SHA 32e7396 dated 2024-Jun-21

The command I used was:

mkdir -p tmp
p4test --dump tmp --top4 FrontEndLast,FrontEndDump,MidEndLast loop-var-modifiable-in-body1.p4

The attached zip file contains the input P4 program, and the contents of the tmp directory created by the command above on my system.
p4c-issue-4739.zip

@jafingerhut
Copy link
Contributor Author

@ChrisDodd Pinging you on this one, in case you have time to look at it.

@ChrisDodd ChrisDodd self-assigned this Jun 22, 2024
@fruffy fruffy added bug This behavior is unintended and should be fixed. core Topics concerning the core segments of the compiler (frontend, midend, parser) labels Jun 22, 2024
@ChrisDodd
Copy link
Contributor

The problem seems to happen in DoSimplifyDefUse -- it seems that it thinks the assignments to i in the loop are dead (have no uses), so they get elimiinated. Not sure why that is happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This behavior is unintended and should be fixed. core Topics concerning the core segments of the compiler (frontend, midend, parser)
Projects
None yet
Development

No branches or pull requests

3 participants