[SLP] Fix CmpInst type handling in cost model
Previously, getValueType() always returned the compared operand type
(e.g. i32) for CmpInst, which was incorrect for gather cost estimation
and codegen where the result type (i1) is needed. This caused ad-hoc
fixups scattered across getEntryCost, calculateTreeCostAndTrimNonProfitable,
and vectorizeTree that overrode ScalarTy back to i1 for CmpInsts.
Add a LookThroughCmp parameter to getValueType() (default: false) so
callers that need the operand type for vector width calculations can
explicitly opt in. This removes the need for the scattered CmpInst
special cases:
- getEntryCost gather path: remove `if (isa<CmpInst>) ScalarTy = i1`
- calculateTreeCostAndTrimNonProfitable: remove same override
- vectorizeTree: simplify `if (!isa<CmpInst>) ScalarTy = getValueType(V)`
to just `getValueType(V)`
For the ICmp/FCmp cost case in getEntryCost, add a fallthrough from
ICmp/FCmp to Select that overrides ScalarTy with the compared operand
type via getValueType(VL0, true), since getCmpSelInstrCost expects the
compared type as its first argument. Fix the condition type argument
passed to getCmpSelInstrCost for both scalar and vector paths: use the
actual condition/result type instead of always Builder.getInt1Ty().
Reviewers: hiraditya, RKSimon
Pull Request: https://github.com/llvm/llvm-project/pull/190618