Open
Description
Similar to #147683
If a ISD::AVG* node has sufficient leading zero/sign bits then it should still work in a truncated type.
- Create alive2 links to prove when all 4 avg patterns can be safely truncated
- Add test coverage (using aarch64 hadd intrinsics is probably easiest as that will always start from the correct nodes)
- Add suitable folds in DAGCombiner::visitTRUNCATE - including legality checks