[llvm] [DAG] expandAVG - attempt to extend to a wider integer type for the add/shift to avoid overflow handling (PR #95788)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 19 02:25:25 PDT 2024
================
@@ -1973,11 +1973,11 @@ define void @not_avg_v16i8_wide_constants(ptr %a, ptr %b) nounwind {
define <1 x i8> @avg_v1i8(<1 x i8> %x, <1 x i8> %y) {
; CHECK-LABEL: avg_v1i8:
; CHECK: # %bb.0:
-; CHECK-NEXT: movl %edi, %eax
-; CHECK-NEXT: orb %sil, %al
-; CHECK-NEXT: xorb %sil, %dil
-; CHECK-NEXT: shrb %dil
-; CHECK-NEXT: subb %dil, %al
+; CHECK-NEXT: movzbl %sil, %eax
+; CHECK-NEXT: movzbl %dil, %ecx
+; CHECK-NEXT: leal 1(%rcx,%rax), %eax
----------------
RKSimon wrote:
avgceilu can be expanded to the or+xor+srl+sub sequence, in that form it doesn't need the increment for rounding without overflow. But when we extend we have spare signbits and can just perform the (a+b+1)>>1 sequence.
https://github.com/llvm/llvm-project/pull/95788
More information about the llvm-commits
mailing list