[llvm] [DAG] fold `avgs(sext(x), sext(y))` -> `sext(avgs(x, y))` (PR #95365)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 13 06:19:08 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
----------------
c8ef wrote:
```
Breakpoint 3, (anonymous namespace)::DAGCombiner::visitAVG (this=0x7ffedb9b5c48, N=0x5580bc91d860) at /workspace/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:5259
5259 SDValue AvgFloorS = DAG.getNode(ISD::AVGFLOORS, DL, X.getValueType(), X, Y);
(gdb) p X.getValueType()
$7 = {V = {SimpleTy = llvm::MVT::v2i32}, LLVMTy = 0x0}
(gdb) p VT
$8 = {V = {SimpleTy = llvm::MVT::v2i32}, LLVMTy = 0x0}
```
It appears that `X.getValueType()` is equal to `VT` here, so the `getNode(sext)` operation becomes a no-op.
https://github.com/llvm/llvm-project/pull/95365
More information about the llvm-commits
mailing list