[all-commits] [llvm/llvm-project] 655d0d: [DAGCombine] Move AVG combine to SimplifyDemandBits
David Green via All-commits
all-commits at lists.llvm.org
Tue Feb 15 02:17:14 PST 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 655d0d86f91bae449459d9e0eb4b0fed3b78a53f
https://github.com/llvm/llvm-project/commit/655d0d86f91bae449459d9e0eb4b0fed3b78a53f
Author: David Green <david.green at arm.com>
Date: 2022-02-15 (Tue, 15 Feb 2022)
Changed paths:
M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
M llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
M llvm/test/CodeGen/AArch64/arm64-vhadd.ll
M llvm/test/CodeGen/AArch64/hadd-combine.ll
M llvm/test/CodeGen/X86/avg.ll
Log Message:
-----------
[DAGCombine] Move AVG combine to SimplifyDemandBits
This moves the matching of AVGFloor and AVGCeil into a place where
demand bit are available, so that it can detect more cases for more
folds. It changes the transform to start from a shift, not from a
truncate. We match the pattern shr(add(ext(A), ext(B)), 1), transforming
to ext(hadd(A, B)).
For signed values, because only the bottom bits are demanded llvm will
transform the above to use a lshr too, as opposed to ashr. In order to
correctly detect the hadd we need to know the demanded bits to turn it
back. Depending on whether the shift is signed (ashr) or logical (lshr),
and the extensions are signed or unsigned we can create different nodes.
If the shift is signed:
Needs >= 2 sign bits. https://alive2.llvm.org/ce/z/h4gQAW generating signed rhadd.
Needs >= 2 zero bits. https://alive2.llvm.org/ce/z/B64DUA generating unsigned rhadd.
If the shift is unsigned:
Needs >= 1 zero bits. https://alive2.llvm.org/ce/z/ByD8sj generating unsigned rhadd.
Needs 1 demanded bit zero and >= 2 sign bits https://alive2.llvm.org/ce/z/hvPGxX and
https://alive2.llvm.org/ce/z/32P5n1 generating signed rhadd.
Differential Revision: https://reviews.llvm.org/D119072
More information about the All-commits
mailing list