feat(ssa): Deduplicate intrinsics with predicates#6615
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Problem*
Resolves #6533
Summary*
Allows
Instruction::Intrinsictypes to be deduplicated inconstant_foldingif theContextis inuse_constraint_infomode, and theIntrinsicis one that doesn't have a side effect other than the possibility of violating an implicit constraint on its inputs, which should be preserved in the first occurrence.Additional Context
I found it a bit confusing why we're using
use_constraint_infofor these whenrequires_acir_gen_predicatereturnsfalsefor all these instructions, which will causecached_instruction_resultsto containNonefor the predicate regardless ofuse_constraint_info. For some, but not all intrinsics, the predicate that tells whether the side effect is enabled is attached to their inputs duringSsa::flatten_cfg, and they don't depend any more on theenable_side_effectinstruction. But it seems like this flag is the one that communicates whether we want such instructions to be deduplicated, so I used it even though I'm not sure what adverse effect we would see if we just returnedtruefor these, other than the implicit coupling by knowing thatflatten_cfghas done things in a certain way.Another method that seems to have some of the truth is
remove_enable_side_effects::Context::responds_to_side_effects_varDocumentation*
Check one:
PR Checklist*
cargo fmton default settings.