[llvm] [DAG] fold `avgs(sext(x), sext(y))` -> `sext(avgs(x, y))` (PR #95365)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 13 04:46:56 PDT 2024


================
@@ -870,10 +866,6 @@ define <4 x i16> @hadd8_zext_lsr(<4 x i8> %src1, <4 x i8> %src2) {
 define <2 x i16> @hadd8x2_sext_asr(<2 x i8> %src1, <2 x i8> %src2) {
 ; CHECK-LABEL: hadd8x2_sext_asr:
 ; CHECK:       // %bb.0:
-; CHECK-NEXT:    shl.2s v1, v1, #24
-; CHECK-NEXT:    shl.2s v0, v0, #24
-; CHECK-NEXT:    sshr.2s v1, v1, #24
-; CHECK-NEXT:    sshr.2s v0, v0, #24
 ; CHECK-NEXT:    shadd.2s v0, v0, v1
----------------
RKSimon wrote:

```
Combining: t24: v2i32 = sign_extend_inreg t23, ValueType:ch:v2i8
 ... into: t23: v2i32 = avgfloors t21, t22
```
This will occur if value tracking has determined the known number of sign bits for the avgfloors result already matches/exceeds what the sign_extend_inreg node would do.

https://github.com/llvm/llvm-project/pull/95365


More information about the llvm-commits mailing list