Skip to content

Commit 98f1e4a

Browse files
authored
[DAG] SelectionDAG::canCreateUndefOrPoison - AVGFLOOR/AVGCEIL don't create undef/poison (#157056)
AVGFLOORS: https://alive2.llvm.org/ce/z/6TdoQ_ AVGFLOORU: https://alive2.llvm.org/ce/z/4pfi4i AVGCEILS: https://alive2.llvm.org/ce/z/nWu8WM AVGCEILU: https://alive2.llvm.org/ce/z/CGvWiA Fixes #147696
1 parent 95fabfd commit 98f1e4a

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5672,6 +5672,10 @@ bool SelectionDAG::canCreateUndefOrPoison(SDValue Op, const APInt &DemandedElts,
56725672
case ISD::USUBSAT:
56735673
case ISD::MULHU:
56745674
case ISD::MULHS:
5675+
case ISD::AVGFLOORS:
5676+
case ISD::AVGFLOORU:
5677+
case ISD::AVGCEILS:
5678+
case ISD::AVGCEILU:
56755679
case ISD::ABDU:
56765680
case ISD::ABDS:
56775681
case ISD::SMIN:

llvm/test/CodeGen/AArch64/freeze.ll

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -430,16 +430,13 @@ define <8 x i16> @freeze_abds(<8 x i16> %a, <8 x i16> %b) {
430430
ret <8 x i16> %r
431431
}
432432

433-
; TODO: Unnecessary final and
434433
define <8 x i16> @freeze_uhadd(<8 x i16> %a0, <8 x i16> %a1) {
435434
; CHECK-LABEL: freeze_uhadd:
436435
; CHECK: // %bb.0:
437436
; CHECK-NEXT: movi v2.8h, #15
438437
; CHECK-NEXT: and v0.16b, v0.16b, v2.16b
439438
; CHECK-NEXT: and v1.16b, v1.16b, v2.16b
440-
; CHECK-NEXT: movi v2.8h, #31
441439
; CHECK-NEXT: uhadd v0.8h, v0.8h, v1.8h
442-
; CHECK-NEXT: and v0.16b, v0.16b, v2.16b
443440
; CHECK-NEXT: ret
444441
%m0 = and <8 x i16> %a0, splat (i16 15)
445442
%m1 = and <8 x i16> %a1, splat (i16 15)
@@ -449,16 +446,13 @@ define <8 x i16> @freeze_uhadd(<8 x i16> %a0, <8 x i16> %a1) {
449446
ret <8 x i16> %masked
450447
}
451448

452-
; TODO: Unnecessary final and
453449
define <8 x i16> @freeze_urhadd(<8 x i16> %a0, <8 x i16> %a1) {
454450
; CHECK-LABEL: freeze_urhadd:
455451
; CHECK: // %bb.0:
456452
; CHECK-NEXT: movi v2.8h, #15
457453
; CHECK-NEXT: and v0.16b, v0.16b, v2.16b
458454
; CHECK-NEXT: and v1.16b, v1.16b, v2.16b
459-
; CHECK-NEXT: movi v2.8h, #31
460455
; CHECK-NEXT: urhadd v0.8h, v0.8h, v1.8h
461-
; CHECK-NEXT: and v0.16b, v0.16b, v2.16b
462456
; CHECK-NEXT: ret
463457
%m0 = and <8 x i16> %a0, splat (i16 15)
464458
%m1 = and <8 x i16> %a1, splat (i16 15)

llvm/test/CodeGen/X86/avg-mask.ll

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,11 @@ define <64 x i8> @avg_v64i8_maskz(<64 x i8> %a, <64 x i8> %b, i64 %mask) nounwin
177177
; AVX512F-NEXT: shrq $32, %rdi
178178
; AVX512F-NEXT: shrq $48, %rax
179179
; AVX512F-NEXT: shrl $16, %ecx
180-
; AVX512F-NEXT: vpavgb %ymm1, %ymm0, %ymm2
181-
; AVX512F-NEXT: vextracti64x4 $1, %zmm1, %ymm1
182-
; AVX512F-NEXT: vextracti64x4 $1, %zmm0, %ymm0
180+
; AVX512F-NEXT: vextracti64x4 $1, %zmm1, %ymm2
181+
; AVX512F-NEXT: vextracti64x4 $1, %zmm0, %ymm3
182+
; AVX512F-NEXT: vpavgb %ymm2, %ymm3, %ymm2
183183
; AVX512F-NEXT: vpavgb %ymm1, %ymm0, %ymm0
184-
; AVX512F-NEXT: vinserti64x4 $1, %ymm0, %zmm2, %zmm0
184+
; AVX512F-NEXT: vinserti64x4 $1, %ymm2, %zmm0, %zmm0
185185
; AVX512F-NEXT: kmovw %ecx, %k2
186186
; AVX512F-NEXT: kmovw %eax, %k3
187187
; AVX512F-NEXT: kmovw %edi, %k4
@@ -364,11 +364,11 @@ define <32 x i16> @avg_v32i16_maskz(<32 x i16> %a, <32 x i16> %b, i32 %mask) nou
364364
; AVX512F: # %bb.0:
365365
; AVX512F-NEXT: kmovw %edi, %k1
366366
; AVX512F-NEXT: shrl $16, %edi
367-
; AVX512F-NEXT: vpavgw %ymm1, %ymm0, %ymm2
368-
; AVX512F-NEXT: vextracti64x4 $1, %zmm1, %ymm1
369-
; AVX512F-NEXT: vextracti64x4 $1, %zmm0, %ymm0
367+
; AVX512F-NEXT: vextracti64x4 $1, %zmm1, %ymm2
368+
; AVX512F-NEXT: vextracti64x4 $1, %zmm0, %ymm3
369+
; AVX512F-NEXT: vpavgw %ymm2, %ymm3, %ymm2
370370
; AVX512F-NEXT: vpavgw %ymm1, %ymm0, %ymm0
371-
; AVX512F-NEXT: vinserti64x4 $1, %ymm0, %zmm2, %zmm0
371+
; AVX512F-NEXT: vinserti64x4 $1, %ymm2, %zmm0, %zmm0
372372
; AVX512F-NEXT: kmovw %edi, %k2
373373
; AVX512F-NEXT: vpternlogd {{.*#+}} zmm1 {%k1} {z} = -1
374374
; AVX512F-NEXT: vpmovdw %zmm1, %ymm1

0 commit comments

Comments
 (0)