[all-commits] [llvm/llvm-project] 08056e: [InstCombine] Generalize sadd.sat combine to compu...
David Green via All-commits
all-commits at lists.llvm.org
Fri Nov 5 08:05:22 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 08056e188869414f64598b9908a84582b817ccb5
https://github.com/llvm/llvm-project/commit/08056e188869414f64598b9908a84582b817ccb5
Author: David Green <david.green at arm.com>
Date: 2021-11-05 (Fri, 05 Nov 2021)
Changed paths:
M llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
M llvm/test/Transforms/InstCombine/sadd_sat.ll
Log Message:
-----------
[InstCombine] Generalize sadd.sat combine to compute sign bits.
There is a combine in instcombine to transform a saturated add/sub into
a saddsat/ssubsat, currently handling inputs which are both sign
extended (https://alive2.llvm.org/ce/z/68qpTn). This can generalize to,
for example ashr of at least the bitwidth (https://alive2.llvm.org/ce/z/4TFyX-
and https://alive2.llvm.org/ce/z/qDWzFs for example). Which means it
generalizes further to "the number of sign bits", needing to be enough
to truncate to the size of the saturate. (An example using `or` for
instance: https://alive2.llvm.org/ce/z/EI_h_A).
So this patch makes use of ComputeNumSignBits (with the newly added
ComputeMinSignedBits) in matchSAddSubSat to generalize the fold to any
inputs with enough sign bits known, truncating the inputs to the new
size of the saturate.
Differential Revision: https://reviews.llvm.org/D112298
More information about the All-commits
mailing list