From patchwork Thu Feb 16 12:47:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 94065 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2488089qgi; Thu, 16 Feb 2017 04:47:40 -0800 (PST) X-Received: by 10.98.155.155 with SMTP id e27mr2419365pfk.140.1487249260705; Thu, 16 Feb 2017 04:47:40 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 32si6901093plf.34.2017.02.16.04.47.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 04:47:40 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-448636-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-448636-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-448636-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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:content-type; q= dns; s=default; b=QqpTVPU53OASSY2SVygmmk2kCw74FRHm+SU7F21vXmZCTm 3e6rvQdOe530hZz6noyV9M7XcJKtHBRTRvHRT23+Sw2GxM+jSQg2nqBn/jlVpydr RhXRV+RGCvinqD97yOpp8nAyyLTZ74ekKtbXmrh9xz3Xwidft/3Kn67E7q+C0= 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:content-type; s= default; bh=pcIqCkPc6IBb9A4fHE6XACCq5mE=; b=AfGFXx5KgvQSlPjT0S54 jkFpgsZvmdmP2CqKtDWPD8uokwawBrY4Pug4QKTHyKQ6N98eqBr3suh8Qag93vMp NvaXOGqn6fDKlk5lcIJhTi4giRzant0oUKlW3C+DJQiQpURgNy1h75jfVxs0c/DD FDbKsP3DQ5WAKTLIoOtaWSM= Received: (qmail 7808 invoked by alias); 16 Feb 2017 12:47:25 -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 7786 invoked by uid 89); 16 Feb 2017 12:47:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=8566, 856, 6, sk:identif, error_at X-HELO: mail-it0-f43.google.com Received: from mail-it0-f43.google.com (HELO mail-it0-f43.google.com) (209.85.214.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 16 Feb 2017 12:47:14 +0000 Received: by mail-it0-f43.google.com with SMTP id x75so22896044itb.0 for ; Thu, 16 Feb 2017 04:47:14 -0800 (PST) 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=4CtGiGPpdQG3YWsTw0ZdKx8HvddZe8+RNOi/4uA+WC4=; b=R9uV/+i4XYZ4mq6SirF3GyXySdZbxzxayya7/BsnxAvmpGWGbLC1AXKcvcLoau0/NL rVXJ6Wvqo+unE+KoDNw018hmz6TQAtzyOQCBbj0iZlk6dnHXqLdHRsSxzkBADoQLB0ga a6f7byd1nl+lKR3Fr3o1ynkX8yUnYMDsuuHFYUjq0rs+2ulYrcWKQbLfQQJHmLBaD0vo Jqe8dSYC2RDfd6LhvEkPSt97YLQjAWwPjB7GMISUOf/ZFa8RimPkTpuUfy4oq9OdlobK wTFx7RpAj82DqsM7+tr6H7oTP8am9Gcwo5YC2oxd5om8YaDHqgGNwV9mquOESx3oWqQt 2Ujw== X-Gm-Message-State: AMke39k9Px5g866gyBGMK20ckRH2L0ySM1hJhrmvOcsFCZEEwse8Ooc9TGXEAIGizpvbZNzW4NF2DNcFbnVz7mbQ X-Received: by 10.107.48.210 with SMTP id w201mr1891765iow.89.1487249232617; Thu, 16 Feb 2017 04:47:12 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.162.13 with HTTP; Thu, 16 Feb 2017 04:47:12 -0800 (PST) From: Prathamesh Kulkarni Date: Thu, 16 Feb 2017 18:17:12 +0530 Message-ID: Subject: [GIMPLE FE] add fma_expr To: Richard Biener , gcc Patches X-IsSubscribed: yes Hi Richard, The attached patch handles fma_expr in gimple-fe. Does it look OK ? Thanks, Prathamesh diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index d959877..fbd4c8c 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -856,6 +856,50 @@ c_parser_gimple_postfix_expression (c_parser *parser) expr.value = fold_convert (type, val); return expr; } + else if (strcmp (IDENTIFIER_POINTER (id), "__FMA") == 0) + { + c_parser_consume_token (parser); + auto_vec args; + + if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) + { + c_parser_gimple_expr_list (parser, &args); + c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, + "expected %<)%>"); + } + if (args.length () != 3) + { + error_at (loc, "invalid number of operands to __FMA"); + expr.value = error_mark_node; + return expr; + } + + tree arg0_type = TREE_TYPE (args[0]); + if (!SCALAR_FLOAT_TYPE_P (arg0_type)) + { + error_at (loc, "operands to __FMA should have" + " floating point type"); + expr.value = error_mark_node; + return expr; + } + + for (int pass = 1; pass < 3; ++pass) + { + tree type = TREE_TYPE (args[pass]); + if (arg0_type != type + || element_precision (arg0_type) != element_precision (type)) + { + error_at (loc, "operands to __FMA should have same type"); + expr.value = error_mark_node; + return expr; + } + } + + expr.value = build3_loc (loc, FMA_EXPR, TREE_TYPE (args[0]), + args[0], args[1], args[2]); + return expr; + } + /* SSA name. */ unsigned version, ver_offset; if (! lookup_name (id) diff --git a/gcc/testsuite/gcc.dg/gimplefe-26.c b/gcc/testsuite/gcc.dg/gimplefe-26.c new file mode 100644 index 0000000..fa5877e --- /dev/null +++ b/gcc/testsuite/gcc.dg/gimplefe-26.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgimple -fdump-tree-ssa-gimple-raw" } */ + +#define foo(type, num) \ +type __GIMPLE () foo_##num (type a, type b, type c) \ +{ \ + type t0; \ + t0_1 = __FMA (a, b, c); \ + return t0_1; \ +} + +foo(float, 1) +foo(double, 2) +foo(long double, 3) + +/* { dg-final { scan-tree-dump-times "fma_expr" 3 "ssa" } } */