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

Fix temporal code motion #7959

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AndreyVV-100
Copy link
Contributor

This commit fixes the pass in some cases where llhd.drv value was created
in the same block. The case can be the result of simple verilog code.

For example:

module Mod(input a, input clk, output logic b);
always @(posedge clk) begin
    b <= ~a;
end
endmodule

Bug can be reproduced by command:

circt-verilog example.sv | circt-opt --llhd-temporal-code-motion

This commit fixes the pass in some cases where llhd.drv value was created
in the same block. The case can be the result of simple verilog code.

For example:

module Mod(input a, input clk, output logic b);
always @(posedge clk) begin
    b <= ~a;
end
endmodule

Bug can be reproduced by command:

circt-verilog example.sv | circt-opt --llhd-temporal-code-motion

Signed-off-by: Andrey Vyazovtsev <[email protected]>
Copy link
Member

@maerhart maerhart left a comment

Choose a reason for hiding this comment

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

Thanks a lot for finding and fixing this issue!

If you run the llhd-early-code-motion pass before temporal code motion, this will not fail. I was thinking about merging the early code motion and temporal code motion passes into an llhd-simplify-processes pass. Maybe we should do that instead of repeating some of its logic here. It should already properly handle block arguments and CFG loops. WDYT?

Comment on lines +109 to +110
auto *op = arg.getDefiningOp();
assert(op && "Using block argument as llhd.drv value is unexpected");
Copy link
Member

Choose a reason for hiding this comment

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

This assumes that passes like block-argument-to-mux are called beforehand. But the pass shouldn't crash if that's not the case, i.e., this should fail with a proper error message or be supported.

Copy link
Contributor Author

@AndreyVV-100 AndreyVV-100 Dec 10, 2024

Choose a reason for hiding this comment

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

I was thinking about merging

Can I try to implement this? Should old passes be deprecated or removed? Should corresponding files be merged or can we just call passes successively in third file?

@AndreyVV-100
Copy link
Contributor Author

If you run the llhd-early-code-motion pass before temporal code motion, this will not fail.

That looks it strange but two days ago I tried to use the pass before llhd-temporal-code-motion and it didn't help me (and my colleague too). I can't reproduce problem now. I think that's my inattention, sorry for useless PR.

I was thinking about merging the early code motion and temporal code motion passes into an llhd-simplify-processes pass

I agree with you. It's unclear that llhd-temporal-code-motion must be executed after llhd-early-code-motion.

@AndreyVV-100
Copy link
Contributor Author

If you run the llhd-early-code-motion pass before temporal code motion, this will not fail.

That looks it strange but two days ago I tried to use the pass before llhd-temporal-code-motion and it didn't help me (and my colleague too). I can't reproduce problem now. I think that's my inattention, sorry for useless PR.

I was thinking about merging the early code motion and temporal code motion passes into an llhd-simplify-processes pass

I agree with you. It's unclear that llhd-temporal-code-motion must be executed after llhd-early-code-motion.

I think that I was confused due to #7963 issue. The PR may be closed.

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

Successfully merging this pull request may close these issues.

2 participants