From patchwork Tue Jul 3 17:38:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 938844 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-480946-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="baXWvXsH"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="mL8X5wie"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41Krv63crNz9s2R for ; Wed, 4 Jul 2018 03:38:26 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:cc:content-type; q=dns; s=default; b=olriNpAp2Ns65ozro7xB7YeDAkl1BJWv4UTIz3cZOMa BG2Yo83dpaO/oT/acWleli5GhuZoxoReUffGcpqhVngAl6pwYoDYRpQPFCSpcgmd VyOKuqsqdj2sTNbBHxyVY1tRIL9ER97+FnitfNvZ2yTkcXkRlu606EglKsJfUtV0 = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:cc:content-type; s=default; bh=c0ZtTMSwzxPgrElmeZWqKUhb76Q=; b=baXWvXsHmfvhigyjx rEPvRgq2A/yO1SbN2hoLQs1mPUhJl2CoF8qJXLtk5E5ecc1uvlf/eei/zT/T6XFR FQAFyZjU+yuOZNw29anWZijuNIMcphXnxl5nHFJdaljD0k+75y1yGQHbcdyOqFok IKCurT4gB70qBmBM1An4X2QtJk= Received: (qmail 110704 invoked by alias); 3 Jul 2018 17:38:19 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 110693 invoked by uid 89); 3 Jul 2018 17:38:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=sk:ix86_fi, offer X-HELO: mail-it0-f48.google.com Received: from mail-it0-f48.google.com (HELO mail-it0-f48.google.com) (209.85.214.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 03 Jul 2018 17:38:17 +0000 Received: by mail-it0-f48.google.com with SMTP id 188-v6so4298109ita.5 for ; Tue, 03 Jul 2018 10:38:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=XoM6o6krvGJO1kJS1o8cfNPKFcr/HnSrKdkuTLt9bCw=; b=mL8X5wiejC+uAiSwUqI4gCX4nKZyXwTl1LJgMjFLMdKZMh8RUjwOfxPKlSwx27VOrb JOFk30sExZXYyo2t6TytliYP87pw5UmbskuT4XhXDAh67VNtuqz3SVAO99DBEqaSkCdv A5smutZVzZVfX79Q2UIGgTstKUMd0b3sgJ5+gpMGTah9V+KZ3sU3cX82SbPFfqpd6aSo NR9WVEbS/QDNSRVqY5+oMCyA4xad7dFPnlfOrNDI8LgfCTWqTpQg8OkL/XwE3RiW/640 F1kdPDFrWmgzrq88WQsxxMKm4NmoRTVDYkIo1d4yFqjZKxU6VjpvOBi8uKF84+euaOqG bY8w== MIME-Version: 1.0 Received: by 2002:a02:2e51:0:0:0:0:0 with HTTP; Tue, 3 Jul 2018 10:38:14 -0700 (PDT) From: Uros Bizjak Date: Tue, 3 Jul 2018 19:38:14 +0200 Message-ID: Subject: [PATCH 18/n, 386]: Fix PR85694, Generation of vectorized AVG (Average) instruction To: "gcc-patches@gcc.gnu.org" Cc: Richard Sandiford Hello! Attached patch implements unsigned HImode and QImode vector average instructions. This is all x86 has to offer... 2018-07-03 Uros Bizjak PR target/85694 * config/i386/sse.md (uavg3_ceil): New expander. (_uavg3): Simplify expander. testsuite/ChangeLog: 2018-07-03 Uros Bizjak PR target/85694 * gcc.target/i386/pr85694.c: New test. Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. Committed to mainline SVN. Uros. Index: config/i386/sse.md =================================================================== --- config/i386/sse.md (revision 262347) +++ config/i386/sse.md (working copy) @@ -10764,6 +10764,24 @@ DONE; }) +(define_expand "uavg3_ceil" + [(set (match_operand:VI12_AVX2 0 "register_operand") + (truncate:VI12_AVX2 + (lshiftrt: + (plus: + (plus: + (zero_extend: + (match_operand:VI12_AVX2 1 "vector_operand")) + (zero_extend: + (match_operand:VI12_AVX2 2 "vector_operand"))) + (match_dup 3)) + (const_int 1))))] + "TARGET_SSE2" +{ + operands[3] = CONST1_RTX(mode); + ix86_fixup_binary_operands_no_copy (PLUS, mode, operands); +}) + (define_expand "usadv16qi" [(match_operand:V4SI 0 "register_operand") (match_operand:V16QI 1 "register_operand") @@ -14234,17 +14252,8 @@ (const_int 1))))] "TARGET_SSE2 && && " { - rtx tmp; - if () - tmp = operands[3]; - operands[3] = CONST1_RTX(mode); + operands[] = CONST1_RTX(mode); ix86_fixup_binary_operands_no_copy (PLUS, mode, operands); - - if () - { - operands[5] = operands[3]; - operands[3] = tmp; - } }) (define_insn "*_uavg3" Index: testsuite/gcc.target/i386/pr85694.c =================================================================== --- testsuite/gcc.target/i386/pr85694.c (nonexistent) +++ testsuite/gcc.target/i386/pr85694.c (working copy) @@ -0,0 +1,18 @@ +/* { dg-do compile } +/* { dg-options "-msse2 -O2 -ftree-vectorize" } */ +/* { dg-final { scan-assembler "pavgb" } } */ +/* { dg-final { scan-assembler "pavgw" } } */ + +#define N 1024 + +#define TEST(TYPE) \ + unsigned TYPE a_##TYPE[N], b_##TYPE[N], c_##TYPE[N]; \ + void f_##TYPE (void) \ + { \ + int i; \ + for (i = 0; i < N; i++) \ + a_##TYPE[i] = (b_##TYPE[i] + c_##TYPE[i] + 1) >> 1; \ + } + +TEST(char); +TEST(short);