[llvm] [AMDGPU][DAG] Allow extract_subvector for free register copy (PR #214152)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 6 19:08:12 PDT 2026
================
@@ -28268,8 +28268,17 @@ SDValue DAGCombiner::visitEXTRACT_SUBVECTOR(SDNode *N) {
V.getOperand(0), NewIndex);
return DAG.getBitcast(NVT, NewExtract);
}
+ // The action for EXTRACT_VECTOR_ELT is registered on the type of the
+ // vector being read, so once operations have been legalized SrcVT is
+ // what decides whether the replacement is really legal. Reading from
+ // an illegal source vector would be promoted straight back into the
+ // extract_subvector we started from.
if (NewExtEC.isScalar() &&
- TLI.isOperationLegalOrCustom(ISD::EXTRACT_VECTOR_ELT, ScalarVT)) {
+ TLI.isOperationLegalOrCustom(ISD::EXTRACT_VECTOR_ELT, SrcVT) &&
+ !(TLI.getTypeAction(*DAG.getContext(), NVT) ==
+ TargetLoweringBase::TypePromoteInteger &&
+ TLI.getTypeAction(*DAG.getContext(), SrcVT) !=
+ TargetLoweringBase::TypePromoteInteger)) {
----------------
Shoreshen wrote:
Hi @arsenm , not changing this will cause infinite loop listed above.
Adding this 2 lines is to avoid the situation that the original bitcase do not need promote, but the new bitcast need.
Letting this situation pass will create extra store + load to unpack the vector type, which create regression on one of the AArch64 case.
https://github.com/llvm/llvm-project/pull/214152
More information about the llvm-commits
mailing list