Open croyzor opened 2 months ago
My understanding is that our usual select
pattern is best because a data dependency is better than a control flow dependency.
Select can be lowered to a conditional move instruction, which is usually better than a conditional branch instruction.
I don't think it really matters, I expect the optimiser can translate between the two representations. We should emit whichever is more convenient. I think that's select
.
Note that we could certainly emit https://llvm.org/docs/LangRef.html#llvm-expect-intrinsic to tell LLVM that the bounds check will very likely succeed.
In some places, we use a pattern (e.g. in the conversions trunc operations) where we run an llvm operaration, and do checks in parallel to see whether we can get away with using the result.
We could instead build a control flow graph where we perform the checks and then branch on the result
Originally posted by @mark-koch in https://github.com/CQCL/hugr-llvm/pull/94#pullrequestreview-2296155819