[all-commits] [llvm/llvm-project] 869e02: [AArch64] Allow cost-free cast absorption into wid...
Kunal Chadha via All-commits
all-commits at lists.llvm.org
Wed Sep 23 04:46:29 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 869e02f412457ebeb3af54e159d550de75127f14
https://github.com/llvm/llvm-project/commit/869e02f412457ebeb3af54e159d550de75127f14
Author: Kunal Chadha <kunachad at qti.qualcomm.com>
Date: 2026-09-23 (Wed, 23 Sep 2026)
Changed paths:
M llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
M llvm/test/Analysis/CostModel/AArch64/free-widening-casts.ll
M llvm/test/CodeGen/AArch64/zext-to-tbl.ll
M llvm/test/Transforms/SLPVectorizer/AArch64/multiple_reduction.ll
Log Message:
-----------
[AArch64] Allow cost-free cast absorption into widening instructions with multiple users (#210460)
Extend getCastInstrCost to recognize cast absorption into widening
instructions (uaddl, saddw, urhadd, etc.) when the cast has multiple
users, not just one.
Previously, the check only looked at a single user (`I->hasOneUser()`),
so a zext/sext feeding more than one widening-eligible instruction was
always costed as non-free, even when every user could individually
absorb it.
This also affected codegen: `optimizeExtendOrTruncateConversion` in
`AArch64ISelLowering.cpp` decides whether to lower a double-widening
zext via tbl shuffles based on whether `getCastInstrCost` reports the
cast as free. With multi-user casts always costed as non-free, this
took the tbl-lowering path in cases where every user could actually
absorb the cast for free, generating unnecessary tbl instructions.
Compiler Explorer:
- Current Assembly: https://godbolt.org/z/hG7oe5h5M
- Expected Assembly: https://godbolt.org/z/EE6xnaxoG
This change factors the per-user check out into
`getUserAbsorbedCastCost()` and applies it across all users of the
cast. The cast is only treated as free if every user can absorb it;
the reported cost is the max of the per-user absorbed costs, to stay
conservative when a partial-widening cost (Src->Src*2) applies for
some user.
Tests:
- free-widening-casts.ll: new cost-model cases with multiple absorbing
users. These cases had a cost of 1 without this change.
- zext-to-tbl.ll: new codegen coverage showing tbl is no longer
generated once the cast is correctly recognized as free.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list