[llvm] [FuncSpec] Improve handling of Comparison Instructions (PR #114073)

Hari Limaye via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 30 16:54:06 PDT 2024


hazzlim wrote:

> Thanks for improving the estimation of the InstCostVisitor. Are there other instructions potentially possible to fold knowing the const range of their operand?

Out of all of the other `visit*` functions in `InstCostVisitor`, I think the only one that would benefit from a similar change would be `visitBinaryOperator(BinaryOperator &I)`.

The case for `visitCmpInst` was simpler, because the common code was already factored into `ValueLatticeElement::getCompare` so we are able to dispatch to that.

I was intending to leave the change for `visitBinaryOperator` to a separate PR as I think it would be a bit more involved - it would potentially be best to factor out some code from `SCCPInstVisitor` to somewhere it could be shared by us (e.g. another function in `ValueLatticeElement`), to avoid duplication:
https://github.com/llvm/llvm-project/blob/51628faa0122d61b7725ec869fa5c0be1d739edd/llvm/lib/Transforms/Utils/SCCPSolver.cpp#L1546-L1584


https://github.com/llvm/llvm-project/pull/114073


More information about the llvm-commits mailing list