From patchwork Mon May 4 19:49:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 467811 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 98F33140549 for ; Tue, 5 May 2015 05:49:51 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=QfK/DPoC; 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=WamK+x56aPIFmSEHbU9Bfpsi3phzuZQOKL78/usy83tJEc jdAFrXckTFV4vUNIvT5uq2NdqLLNwZdIdMulKJxfyeHp1tWkPQvCcoGnA/I0ZDmD YHZoPms+ipaXRZq9885lKGE8gTRYN8ycItIOshvtw+X8zd7EkZQARdNZTyJQg= 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=CuCtZGN6chKAEf1oF6jrU8FlkPI=; b=QfK/DPoCMAdgtts5Lbxo uot6vpkTP4gDm4eN7nPx8QeoIno5lLO07C+1+yAtcQQoUEVDB8G2e2WjQRV8BZWz WA/N/B1q3qY8wiUgKAboNCn9CiDxChdYRoa6Genn8yemUspSGwMLt4p5tDVLqdbA 207qhp45wLICQVBBhTjzAHc= Received: (qmail 22302 invoked by alias); 4 May 2015 19:49:43 -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 22282 invoked by uid 89); 4 May 2015 19:49:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-oi0-f44.google.com Received: from mail-oi0-f44.google.com (HELO mail-oi0-f44.google.com) (209.85.218.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 04 May 2015 19:49:41 +0000 Received: by oica37 with SMTP id a37so120796301oic.0 for ; Mon, 04 May 2015 12:49:39 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.202.83.202 with SMTP id h193mr18376120oib.56.1430768979258; Mon, 04 May 2015 12:49:39 -0700 (PDT) Received: by 10.60.147.170 with HTTP; Mon, 4 May 2015 12:49:39 -0700 (PDT) Date: Mon, 4 May 2015 21:49:39 +0200 Message-ID: Subject: [PATCH, i386]: Some trivial const_wide_int/const_double related cleanups From: Uros Bizjak To: "gcc-patches@gcc.gnu.org" Hello! 2015-05-04 Uros Bizjak * config/i386/i386.c: Change GET_CODE (...) == CONST_DOUBLE check to CONST_DOUBLE_P predicate. (standard_sse_constant_p): Return 0 for !TARGET_SSE. (ix86_legitimate_constant_p) : For 32bit targets, allow only operands that satisfy standard_sse_constant_p predicate. * config/i386/i386.md: Change GET_CODE (...) == CONST_DOUBLE check to CONST_DOUBLE_P predicate. Tested on x86_64-linux-gnu {,-m32} and committed to mainline SVN. Uros. Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 222767) +++ config/i386/i386.c (working copy) @@ -9368,7 +9368,7 @@ standard_80387_constant_p (rtx x) REAL_VALUE_TYPE r; - if (!(X87_FLOAT_MODE_P (mode) && (GET_CODE (x) == CONST_DOUBLE))) + if (!(CONST_DOUBLE_P (x) && X87_FLOAT_MODE_P (mode))) return -1; if (x == CONST0_RTX (mode)) @@ -9469,9 +9469,14 @@ standard_80387_constant_rtx (int idx) int standard_sse_constant_p (rtx x) { - machine_mode mode = GET_MODE (x); + machine_mode mode; - if (x == const0_rtx || x == CONST0_RTX (GET_MODE (x))) + if (!TARGET_SSE) + return 0; + + mode = GET_MODE (x); + + if (x == const0_rtx || x == CONST0_RTX (mode)) return 1; if (vector_all_ones_operand (x, mode)) switch (mode) @@ -13078,9 +13083,7 @@ ix86_legitimate_constant_p (machine_mode, rtx x) break; case CONST_WIDE_INT: - if (GET_MODE (x) == TImode - && x != CONST0_RTX (TImode) - && !TARGET_64BIT) + if (!TARGET_64BIT && !standard_sse_constant_p (x)) return false; break; @@ -15903,7 +15906,7 @@ ix86_print_operand (FILE *file, rtx x, int code) output_address (x); } - else if (GET_CODE (x) == CONST_DOUBLE && GET_MODE (x) == SFmode) + else if (CONST_DOUBLE_P (x) && GET_MODE (x) == SFmode) { REAL_VALUE_TYPE r; long l; @@ -15921,7 +15924,7 @@ ix86_print_operand (FILE *file, rtx x, int code) fprintf (file, "0x%08x", (unsigned int) l); } - else if (GET_CODE (x) == CONST_DOUBLE && GET_MODE (x) == DFmode) + else if (CONST_DOUBLE_P (x) && GET_MODE (x) == DFmode) { REAL_VALUE_TYPE r; long l[2]; @@ -15935,7 +15938,7 @@ ix86_print_operand (FILE *file, rtx x, int code) } /* These float cases don't actually occur as immediate operands. */ - else if (GET_CODE (x) == CONST_DOUBLE && GET_MODE (x) == XFmode) + else if (CONST_DOUBLE_P (x) && GET_MODE (x) == XFmode) { char dstr[30]; @@ -17364,8 +17367,7 @@ ix86_expand_move (machine_mode mode, rtx operands[ op1 = copy_to_mode_reg (mode, op1); if (can_create_pseudo_p () - && FLOAT_MODE_P (mode) - && GET_CODE (op1) == CONST_DOUBLE) + && CONST_DOUBLE_P (op1)) { /* If we are loading a floating point constant to a register, force the value to memory now, since we'll get better code @@ -19563,7 +19565,7 @@ ix86_expand_copysign (rtx operands[]) else vmode = mode; - if (GET_CODE (op0) == CONST_DOUBLE) + if (CONST_DOUBLE_P (op0)) { rtx (*copysign_insn)(rtx, rtx, rtx, rtx); @@ -22632,7 +22634,7 @@ ix86_split_to_parts (rtx operand, rtx *parts, mach for (i = 1; i < size; i++) parts[i] = adjust_address (operand, SImode, 4 * i); } - else if (GET_CODE (operand) == CONST_DOUBLE) + else if (CONST_DOUBLE_P (operand)) { REAL_VALUE_TYPE r; long l[4]; @@ -22683,7 +22685,7 @@ ix86_split_to_parts (rtx operand, rtx *parts, mach parts[0] = operand; parts[1] = adjust_address (operand, upper_mode, 8); } - else if (GET_CODE (operand) == CONST_DOUBLE) + else if (CONST_DOUBLE_P (operand)) { REAL_VALUE_TYPE r; long l[4]; @@ -41208,7 +41210,7 @@ ix86_preferred_reload_class (rtx x, reg_class_t re return SSE_CLASS_P (regclass) ? regclass : NO_REGS; /* Floating-point constants need more complex checks. */ - if (GET_CODE (x) == CONST_DOUBLE && GET_MODE (x) != VOIDmode) + if (CONST_DOUBLE_P (x)) { /* General regs can load everything. */ if (reg_class_subset_p (regclass, GENERAL_REGS)) @@ -44551,9 +44553,9 @@ ix86_expand_vector_init (bool mmx_ok, rtx target, for (i = 0; i < n_elts; ++i) { x = XVECEXP (vals, 0, i); - if (!(CONST_INT_P (x) - || GET_CODE (x) == CONST_DOUBLE - || GET_CODE (x) == CONST_FIXED)) + if (!(CONST_SCALAR_INT_P (x) + || CONST_DOUBLE_P (x) + || CONST_FIXED_P (x))) n_var++, one_var = i; else if (x != CONST0_RTX (inner_mode)) all_const_zero = false; Index: config/i386/i386.md =================================================================== --- config/i386/i386.md (revision 222767) +++ config/i386/i386.md (working copy) @@ -2955,7 +2955,7 @@ && !(MEM_P (operands[0]) && MEM_P (operands[1])) && (!can_create_pseudo_p () || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE) - || GET_CODE (operands[1]) != CONST_DOUBLE + || !CONST_DOUBLE_P (operands[1]) || (optimize_function_for_size_p (cfun) && standard_sse_constant_p (operands[1]) && !memory_operand (operands[0], TFmode)) @@ -3025,7 +3025,7 @@ "!(MEM_P (operands[0]) && MEM_P (operands[1])) && (!can_create_pseudo_p () || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE) - || GET_CODE (operands[1]) != CONST_DOUBLE + || !CONST_DOUBLE_P (operands[1]) || (optimize_function_for_size_p (cfun) && standard_80387_constant_p (operands[1]) > 0 && !memory_operand (operands[0], XFmode)) @@ -3079,7 +3079,7 @@ "!(MEM_P (operands[0]) && MEM_P (operands[1])) && (!can_create_pseudo_p () || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE) - || GET_CODE (operands[1]) != CONST_DOUBLE + || !CONST_DOUBLE_P (operands[1]) || (optimize_function_for_size_p (cfun) && ((!(TARGET_SSE2 && TARGET_SSE_MATH) && standard_80387_constant_p (operands[1]) > 0) @@ -3262,7 +3262,7 @@ "!(MEM_P (operands[0]) && MEM_P (operands[1])) && (!can_create_pseudo_p () || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE) - || GET_CODE (operands[1]) != CONST_DOUBLE + || !CONST_DOUBLE_P (operands[1]) || (optimize_function_for_size_p (cfun) && ((!TARGET_SSE_MATH && standard_80387_constant_p (operands[1]) > 0) @@ -3961,7 +3961,7 @@ { /* ??? Needed for compress_float_constant since all fp constants are TARGET_LEGITIMATE_CONSTANT_P. */ - if (GET_CODE (operands[1]) == CONST_DOUBLE) + if (CONST_DOUBLE_P (operands[1])) { if ((!TARGET_SSE2 || TARGET_MIX_SSE_I387) && standard_80387_constant_p (operands[1]) > 0) @@ -4077,7 +4077,7 @@ { /* ??? Needed for compress_float_constant since all fp constants are TARGET_LEGITIMATE_CONSTANT_P. */ - if (GET_CODE (operands[1]) == CONST_DOUBLE) + if (CONST_DOUBLE_P (operands[1])) { if (standard_80387_constant_p (operands[1]) > 0) {