From patchwork Mon Apr 25 19:16:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 614597 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3qtwvn4sGLz9sBg for ; Tue, 26 Apr 2016 05:17:07 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=PFFLNpzX; dkim-atps=neutral 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:date:message-id:subject:from:to:content-type; q= dns; s=default; b=t0vq3CYyayMvw4QSCMEMzBssu2K5fkBlqTZwSe4oJk8iia Y3OVSY0ECd4Ry0AQHinB0wjGyapJFspvAJu/n5ojlHWBqefsOtVU0MBiqQqF61s1 oKixglzQcFU/udrEeGtH8WwyhW7FTp9QMRV98TRO/FhD92y0iQy4sgE6n8FRk= 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:date:message-id:subject:from:to:content-type; s= default; bh=reeGlKtJuDSbwSpqnZuGaI6MBzw=; b=PFFLNpzXU/q0dmG2deBK lBJHA6A/yA5pf0fAKmCS10rK27wXCJtbdT35nykmeluWy9qFKB1aUKoa7UcBovKj n2Kd65nx514HIuGz6q3kme5F3GnNyYW6Z73nn17s5k+whYDQxr/4goAOIvVUinXe +K0hu74S0IpRglEODlU++cY= Received: (qmail 117266 invoked by alias); 25 Apr 2016 19:17:00 -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 117252 invoked by uid 89); 25 Apr 2016 19:16:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.9 required=5.0 tests=BAYES_50, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 spammy=ubizjak@gmail.com, ubizjakgmailcom, sk:define_, constm1_rtx X-HELO: mail-vk0-f43.google.com Received: from mail-vk0-f43.google.com (HELO mail-vk0-f43.google.com) (209.85.213.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 25 Apr 2016 19:16:49 +0000 Received: by mail-vk0-f43.google.com with SMTP id n67so3122442vkf.3 for ; Mon, 25 Apr 2016 12:16:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=CEmih6uTHntKjkZwtFVlYp/ooi/jEX9E+/DwLyAysIg=; b=DNVAyyZLaGTJymuX3KTqkaYduNypanmVvnuiwDY6EEMDsIGR3uDNhToIwtnTxSQ/8l f4oP/BBZPmK3bqn/1vmjEdXtx3NmJSqeDQPiQNb/7CL+uTqfWADQYvPupcIAxMd400SD v7XMd5Oz3CaNZXOt64tNQnjX/Kc2rKB46vRQD+5WU0pYLC0HeGpGZAVBe9V24XWes5Lj 2f8H1Z98cyBz1Oqa+izD2eTogc1EUM5mOHIhrLOjWavYMyIk4TPoL5ypyRDkY45QE0sn Cms3IWaYrF56oNBhVxHQlyWVOMhRxZv/Y+ozqvRAB6QYUuXxqSWj+m+/rHacOHnOVRdH V27Q== X-Gm-Message-State: AOPr4FUnETxho/eBaZszjyIVtrts2QCV9pANVb85Cp71rxjQMQ1n4kvUVaBpnCd0+t5P7F7/lk5Srd5VkGAMag== MIME-Version: 1.0 X-Received: by 10.176.64.40 with SMTP id h37mr11519230uad.58.1461611807312; Mon, 25 Apr 2016 12:16:47 -0700 (PDT) Received: by 10.103.76.220 with HTTP; Mon, 25 Apr 2016 12:16:47 -0700 (PDT) Date: Mon, 25 Apr 2016 21:16:47 +0200 Message-ID: Subject: [PATCH, i386]: Simplify emission of SSE constant (-1) load. From: Uros Bizjak To: "gcc-patches@gcc.gnu.org" 2016-04-25 Uros Bizjak * config/i386/i386.md (*movoi_internal_avx): Set mode attribute to XI for SSE constm1 operands and TARGET_AVX512VL. (*movti_internal): Ditto. (*mov_or): Use constm1_operand predicate. * config/i386/sse.md (*mov_internal): Set mode attribute to XI for SSE vector_all_ones operands and TARGET_AVX512VL. * config/i386/predicates.md (constm1_operand): New predicate. * config/i386/i386.c (standard_sse_constant_opcode): Simplify emission of constant -1 load. Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. Committed to mainline SVN. Uros. Index: i386.c =================================================================== --- i386.c (revision 235411) +++ i386.c (working copy) @@ -10868,30 +10868,24 @@ standard_sse_constant_opcode (rtx_insn *insn, rtx case MODE_V8DF: case MODE_V16SF: gcc_assert (TARGET_AVX512F); - break; + return "vpternlogd\t{$0xFF, %g0, %g0, %g0|%g0, %g0, %g0, 0xFF}"; + case MODE_OI: case MODE_V4DF: case MODE_V8SF: gcc_assert (TARGET_AVX2); - break; + /* FALLTHRU */ case MODE_TI: case MODE_V2DF: case MODE_V4SF: gcc_assert (TARGET_SSE2); - break; + return (TARGET_AVX + ? "vpcmpeqd\t%0, %0, %0" + : "pcmpeqd\t%0, %0"); + default: gcc_unreachable (); } - - if (TARGET_AVX512VL - || insn_mode == MODE_XI - || insn_mode == MODE_V8DF - || insn_mode == MODE_V16SF) - return "vpternlogd\t{$0xFF, %g0, %g0, %g0|%g0, %g0, %g0, 0xFF}"; - else if (TARGET_AVX) - return "vpcmpeqd\t%0, %0, %0"; - else - return "pcmpeqd\t%0, %0"; } gcc_unreachable (); Index: i386.md =================================================================== --- i386.md (revision 235411) +++ i386.md (working copy) @@ -1960,10 +1960,9 @@ (define_insn "*mov_or" [(set (match_operand:SWI48 0 "register_operand" "=r") - (match_operand:SWI48 1 "const_int_operand")) + (match_operand:SWI48 1 "constm1_operand")) (clobber (reg:CC FLAGS_REG))] - "reload_completed - && operands[1] == constm1_rtx" + "reload_completed" "or{}\t{%1, %0|%0, %1}" [(set_attr "type" "alu1") (set_attr "mode" "") @@ -2039,11 +2038,14 @@ (cond [(ior (match_operand 0 "ext_sse_reg_operand") (match_operand 1 "ext_sse_reg_operand")) (const_string "XI") - (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL") + (and (eq_attr "alternative" "0") + (and (match_test "TARGET_AVX512VL") + (match_operand 1 "constm1_operand"))) + (const_string "XI") + (ior (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL") + (and (eq_attr "alternative" "3") + (match_test "TARGET_SSE_TYPELESS_STORES"))) (const_string "V8SF") - (and (eq_attr "alternative" "3") - (match_test "TARGET_SSE_TYPELESS_STORES")) - (const_string "V8SF") ] (const_string "OI")))]) @@ -2099,17 +2101,20 @@ (const_string "maybe_vex") (const_string "orig"))) (set (attr "mode") - (cond [(ior (match_operand 0 "ext_sse_reg_operand") + (cond [(eq_attr "alternative" "0,1") + (const_string "DI") + (ior (match_operand 0 "ext_sse_reg_operand") (match_operand 1 "ext_sse_reg_operand")) (const_string "XI") - (eq_attr "alternative" "0,1") - (const_string "DI") + (and (eq_attr "alternative" "2") + (and (match_test "TARGET_AVX512VL") + (match_operand 1 "constm1_operand"))) + (const_string "XI") (ior (not (match_test "TARGET_SSE2")) - (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")) + (ior (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL") + (and (eq_attr "alternative" "5") + (match_test "TARGET_SSE_TYPELESS_STORES")))) (const_string "V4SF") - (and (eq_attr "alternative" "5") - (match_test "TARGET_SSE_TYPELESS_STORES")) - (const_string "V4SF") (match_test "TARGET_AVX") (const_string "TI") (match_test "optimize_function_for_size_p (cfun)") Index: predicates.md =================================================================== --- predicates.md (revision 235411) +++ predicates.md (working copy) @@ -675,6 +675,11 @@ return op == CONST1_RTX (mode); }) +;; Match exactly -1. +(define_predicate "constm1_operand" + (and (match_code "const_int") + (match_test "op = constm1_rtx"))) + ;; Match exactly eight. (define_predicate "const8_operand" (and (match_code "const_int") Index: sse.md =================================================================== --- sse.md (revision 235411) +++ sse.md (working copy) @@ -938,7 +938,11 @@ [(set_attr "type" "sselog1,ssemov,ssemov") (set_attr "prefix" "maybe_vex") (set (attr "mode") - (cond [(and (match_test " == 16") + (cond [(and (eq_attr "alternative" "0") + (and (match_test "TARGET_AVX512VL") + (match_operand 1 "vector_all_ones_operand"))) + (const_string "XI") + (and (match_test " == 16") (ior (match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL") (and (eq_attr "alternative" "2") (match_test "TARGET_SSE_TYPELESS_STORES"))))