From patchwork Tue May 12 17:28:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 1288672 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=dcRsQ2K+; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49M4Xq6JyCz9sRK for ; Wed, 13 May 2020 03:28:59 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D047D38930C9; Tue, 12 May 2020 17:28:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D047D38930C9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1589304532; bh=afEfz9etkJIvPts52OQj+YKbLJw2TAGrOU10mnaUaaI=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=dcRsQ2K+e/X69trCpG9jz2rzVTIY/klZjEFYK3QE3V1mcKu9lleSdg77xkRoqSxkz 8nL/mwvcTJxuiK4Y/mQzXlsVDV7+Jck/clHOu9oIzUpbhvI9tSk99KAfpYgY3JSeK3 RdeIA46Z7/z2RFSqvAQTQxYFL//PO17ovGq7oIqg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by sourceware.org (Postfix) with ESMTPS id 424F6386F447 for ; Tue, 12 May 2020 17:28:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 424F6386F447 Received: by mail-io1-xd2b.google.com with SMTP id s10so14892330iog.7 for ; Tue, 12 May 2020 10:28:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=afEfz9etkJIvPts52OQj+YKbLJw2TAGrOU10mnaUaaI=; b=tbneaquT/g7p1cwbXBb/jOZRI2IbyrUdmopm8VsHuyzKBvSyR5rHwhfFYVmE/d5pex JiE4jvbQFQkaIkS1/jcWBJeGfkWVOSrj6PvKBILY8rWdlHOyRygfAFapDAynjNcaA0ff gYL8bwaUYqyGzI7qRzehVq/SEFVUFNfApgyKR07f7wCUNlbtu6aSKITbX6LFtzaSoPfE S6gGFaRtCY0wKxJdqkAP02WfEu75uVlPcK+bff4NWUvK68ZvAr8EmFfrmX/vdFeiODMT twQZCtqUeps4DScX71OGFERoQlZbi5+BKCfvd8hVmEce/fE46nQodOKdV0aP/9u//3P1 C7Qw== X-Gm-Message-State: AGi0Pua+PwTawbDivepuGMn1nBNIVaTk6tnWA4mpVVm50wfy2pkfuWch 04oQ8K9+EMYV4UhlTt/liW1FPSvgPTLycOB7yUQYVpSDmZk= X-Google-Smtp-Source: APiQypJLqNjCqlHgstm0SApOuWCM2dkP7JQu+3NucX2pr1usdI5fAnDPjmvuUhQ9Q1KrfUB48Zxiuh226oPLGRoTvRA= X-Received: by 2002:a02:245:: with SMTP id 66mr21942149jau.69.1589304529327; Tue, 12 May 2020 10:28:49 -0700 (PDT) MIME-Version: 1.0 Date: Tue, 12 May 2020 19:28:37 +0200 Message-ID: Subject: [committed] i386: Add V2SFmode copysign, xorsign and signbit expanders [PR95046] To: "gcc-patches@gcc.gnu.org" X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Uros Bizjak via Gcc-patches From: Uros Bizjak Reply-To: Uros Bizjak Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" gcc/ChangeLog: 2020-05-12 Uroš Bizjak PR target/95046 * config/i386/mmx.md (copysignv2sf3): New expander. (xorsignv2sf3): Ditto. (signbitv2sf3): Ditto. testsuite/ChangeLog: 2020-05-12 Uroš Bizjak PR target/95046 * gcc.target/i386/pr95046-4.c: New test. Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. Uros. diff --git a/gcc/config/i386/mmx.md b/gcc/config/i386/mmx.md index f6f302eb7ff..d159134e0fb 100644 --- a/gcc/config/i386/mmx.md +++ b/gcc/config/i386/mmx.md @@ -660,6 +660,47 @@ (set_attr "prefix" "orig,vex") (set_attr "mode" "V4SF")]) +(define_expand "copysignv2sf3" + [(set (match_dup 4) + (and:V2SF + (not:V2SF (match_dup 3)) + (match_operand:V2SF 1 "register_operand"))) + (set (match_dup 5) + (and:V2SF (match_dup 3) + (match_operand:V2SF 2 "register_operand"))) + (set (match_operand:V2SF 0 "register_operand") + (ior:V2SF (match_dup 4) (match_dup 5)))] + "TARGET_MMX_WITH_SSE" +{ + operands[3] = ix86_build_signbit_mask (V2SFmode, true, false); + + operands[4] = gen_reg_rtx (V2SFmode); + operands[5] = gen_reg_rtx (V2SFmode); +}) + +(define_expand "xorsignv2sf3" + [(set (match_dup 4) + (and:V2SF (match_dup 3) + (match_operand:V2SF 2 "register_operand"))) + (set (match_operand:V2SF 0 "register_operand") + (xor:V2SF (match_dup 4) + (match_operand:V2SF 1 "register_operand")))] + "TARGET_MMX_WITH_SSE" +{ + operands[3] = ix86_build_signbit_mask (V2SFmode, true, false); + + operands[4] = gen_reg_rtx (V2SFmode); +}) + +(define_expand "signbitv2sf2" + [(set (match_operand:V2SI 0 "register_operand") + (lshiftrt:V2SI + (subreg:V2SI + (match_operand:V2SF 1 "register_operand") 0) + (match_dup 2)))] + "TARGET_MMX_WITH_SSE" + "operands[2] = GEN_INT (GET_MODE_UNIT_BITSIZE (V2SFmode)-1);") + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Parallel single-precision FMA multiply/accumulate instructions. diff --git a/gcc/testsuite/gcc.target/i386/pr95046-4.c b/gcc/testsuite/gcc.target/i386/pr95046-4.c new file mode 100644 index 00000000000..5a85045b095 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr95046-4.c @@ -0,0 +1,39 @@ +/* PR target/95046 */ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O3 -msse2" } */ + + +float r[2], a[2], b[2]; + +float copysignf (float, float); + +void +test_copysign (void) +{ + for (int i = 0; i < 2; i++) + r[i] = copysignf (a[i], b[i]); +} + +/* { dg-final { scan-assembler "\tv?andnps" } } */ + +void +test_xorsign (void) +{ + for (int i = 0; i < 2; i++) + r[i] = a[i] * copysignf (1.0f, b[i]); +} + +/* { dg-final { scan-assembler "\tv?xorps" } } */ + +int s[2]; + +int signbitf (float); + +void +test_signbitf (void) +{ + for (int i = 0; i < 2; i++) + s[i] = signbitf (a[i]); +} + +/* { dg-final { scan-assembler "\tv?psrld" } } */