From patchwork Mon Jun 18 14:59:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 930959 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-479929-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="EHT7VdyL"; 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 418Z5S5TRcz9s19 for ; Tue, 19 Jun 2018 01:00:12 +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:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=cm3G9RApLM3kQCi4qPNZdqQBvgrGbWu88KoCQWeffvnfm6B4OJHvK vWYvExLjk3I+WfShV8HB6XVjMXQvuxQCficPymQiDya+5uMU8Sg75O6NBUBviCq/ ZBlMYEsD6IWK0+rGC6RsWOTVCcvjSefGyrH4iBFS3vwpWRLYA22eGQ= 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:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=reufn45MxrlZSf8YIfcVvDfDFg4=; b=EHT7VdyLu7SEdRg1ZYpD CwxgeFZ3AUVM1LGZj6397gvpSyxWNUaU5a1c8OQ0TpNhcHvGk4QZboQ6iTa7qZib vggoOTRLkXwMuDmRlNdxZCXItuxknVLEBaJvfJo5frtHeXhozAh6NVTp8iGZ5YNv haYT3hap+eHvIkx5BENe5TI= Received: (qmail 127171 invoked by alias); 18 Jun 2018 15:00:03 -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 127064 invoked by uid 89); 18 Jun 2018 15:00:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: foss.arm.com Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 18 Jun 2018 14:59:58 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7554F1529 for ; Mon, 18 Jun 2018 07:59:57 -0700 (PDT) Received: from localhost (unknown [10.32.98.107]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F06BD3F557 for ; Mon, 18 Jun 2018 07:59:56 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [7/n] PR85694: Add a vect_pattern_detected helper Date: Mon, 18 Jun 2018 15:59:55 +0100 Message-ID: <87sh5kf8d0.fsf@arm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 This message is a long write-up for a patch that simply adds a common routine for printing the "vector_foo_pattern: detected:" messages. The reason for doing this is that some routines check for target support themselves and some leave it to vect_pattern_recog_1. Those that leave it to vect_pattern_recog_1 currently print these "detected:" messages if the statements have the right form, even if the pattern is eventually discarded. IMO that's useful, and a lot of existing scan tests rely on it. However, a later patch makes patterns do their own testing, and stops them creating pattern statements until the tests have passed. This means (a) they need to print the "detected:" message earlier and (b) the pattern statement won't be around to print. The patch therefore makes all routines print the original statement rather than the pattern one. That information isn't obvious otherwise, whereas vect_pattern_recog_1 already prints the pattern statement in the case of a successful match. This also avoids the previous situation in which a routine could print "detected:" and then silently bail out before saying what had been detected. Tested on aarch64-linux-gnu and x86_64-linux-gnu. OK to install? Richard 2018-06-18 Richard Sandiford gcc/ * tree-vect-patterns.c (vect_pattern_detected): New function. (vect_recog_dot_prod_patternm, vect_recog_sad_pattern) (vect_recog_widen_mult_pattern, vect_recog_widen_sum_pattern) (vect_recog_over_widening_pattern, vect_recog_widen_shift_pattern (vect_recog_rotate_pattern, vect_recog_vector_vector_shift_pattern) (vect_recog_mult_pattern, vect_recog_divmod_pattern) (vect_recog_mixed_size_cond_pattern, vect_recog_bool_pattern) (vect_recog_mask_conversion_pattern) (vect_try_gather_scatter_pattern): Likewise. Index: gcc/tree-vect-patterns.c =================================================================== --- gcc/tree-vect-patterns.c 2018-06-18 15:41:33.332272879 +0100 +++ gcc/tree-vect-patterns.c 2018-06-18 15:43:18.327344801 +0100 @@ -107,6 +107,19 @@ static vect_recog_func vect_vect_recog_f { vect_recog_mask_conversion_pattern, "mask_conversion" } }; +/* Report that we've found an instance of pattern PATTERN in + statement STMT. */ + +static void +vect_pattern_detected (const char *name, gimple *stmt) +{ + if (dump_enabled_p ()) + { + dump_printf_loc (MSG_NOTE, vect_location, "%s: detected: ", name); + dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0); + } +} + static inline void append_pattern_def_seq (stmt_vec_info stmt_info, gimple *stmt) { @@ -432,22 +445,16 @@ vect_recog_dot_prod_pattern (vec *s || TYPE_PRECISION (sum_type) < TYPE_PRECISION (half_type0) * 2) return NULL; + vect_pattern_detected ("vect_recog_sad_pattern", last_stmt); + *type_in = TREE_TYPE (sad_oprnd0); *type_out = sum_type; - /* Pattern detected. Create a stmt to be used to replace the pattern: */ tree var = vect_recog_temp_ssa_var (sum_type, NULL); gimple *pattern_stmt = gimple_build_assign (var, SAD_EXPR, sad_oprnd0, sad_oprnd1, plus_oprnd1); - if (dump_enabled_p ()) - { - dump_printf_loc (MSG_NOTE, vect_location, - "vect_recog_sad_pattern: detected: "); - dump_gimple_stmt (MSG_NOTE, TDF_SLIM, pattern_stmt, 0); - } - return pattern_stmt; } @@ -919,9 +920,7 @@ vect_recog_widen_mult_pattern (vecsafe_push (last_stmt); return pattern_stmt; } @@ -1230,20 +1226,15 @@ vect_recog_widen_sum_pattern (veclast ()); return pattern_stmt; } @@ -1740,9 +1726,7 @@ vect_recog_widen_shift_pattern (vecsafe_push (last_stmt); return pattern_stmt; } @@ -2010,17 +1991,12 @@ vect_recog_rotate_pattern (vec append_pattern_def_seq (stmt_vinfo, def_stmt); /* Pattern detected. */ - if (dump_enabled_p ()) - dump_printf_loc (MSG_NOTE, vect_location, - "vect_recog_rotate_pattern: detected:\n"); + vect_pattern_detected ("vect_recog_rotate_pattern", last_stmt); /* Pattern supported. Create a stmt to be used to replace the pattern. */ var = vect_recog_temp_ssa_var (type, NULL); pattern_stmt = gimple_build_assign (var, BIT_IOR_EXPR, var1, var2); - if (dump_enabled_p ()) - dump_gimple_stmt_loc (MSG_NOTE, vect_location, TDF_SLIM, pattern_stmt, 0); - stmts->safe_push (last_stmt); return pattern_stmt; } @@ -2153,17 +2129,12 @@ vect_recog_vector_vector_shift_pattern ( } /* Pattern detected. */ - if (dump_enabled_p ()) - dump_printf_loc (MSG_NOTE, vect_location, - "vect_recog_vector_vector_shift_pattern: detected:\n"); + vect_pattern_detected ("vect_recog_vector_vector_shift_pattern", last_stmt); /* Pattern supported. Create a stmt to be used to replace the pattern. */ var = vect_recog_temp_ssa_var (TREE_TYPE (oprnd0), NULL); pattern_stmt = gimple_build_assign (var, rhs_code, oprnd0, def); - if (dump_enabled_p ()) - dump_gimple_stmt_loc (MSG_NOTE, vect_location, TDF_SLIM, pattern_stmt, 0); - stmts->safe_push (last_stmt); return pattern_stmt; } @@ -2530,13 +2501,7 @@ vect_recog_mult_pattern (vec * return NULL; /* Pattern detected. */ - if (dump_enabled_p ()) - dump_printf_loc (MSG_NOTE, vect_location, - "vect_recog_mult_pattern: detected:\n"); - - if (dump_enabled_p ()) - dump_gimple_stmt_loc (MSG_NOTE, vect_location, TDF_SLIM, - pattern_stmt,0); + vect_pattern_detected ("vect_recog_mult_pattern", last_stmt); stmts->safe_push (last_stmt); *type_in = vectype; @@ -2652,9 +2617,7 @@ vect_recog_divmod_pattern (vec return NULL; /* Pattern detected. */ - if (dump_enabled_p ()) - dump_printf_loc (MSG_NOTE, vect_location, - "vect_recog_divmod_pattern: detected:\n"); + vect_pattern_detected ("vect_recog_divmod_pattern", last_stmt); cond = build2 (LT_EXPR, boolean_type_node, oprnd0, build_int_cst (itype, 0)); @@ -2738,10 +2701,6 @@ vect_recog_divmod_pattern (vec signmask); } - if (dump_enabled_p ()) - dump_gimple_stmt_loc (MSG_NOTE, vect_location, TDF_SLIM, pattern_stmt, - 0); - stmts->safe_push (last_stmt); *type_in = vectype; @@ -2992,12 +2951,7 @@ vect_recog_divmod_pattern (vec } /* Pattern detected. */ - if (dump_enabled_p ()) - { - dump_printf_loc (MSG_NOTE, vect_location, - "vect_recog_divmod_pattern: detected: "); - dump_gimple_stmt (MSG_NOTE, TDF_SLIM, pattern_stmt, 0); - } + vect_pattern_detected ("vect_recog_divmod_pattern", last_stmt); stmts->safe_push (last_stmt); @@ -3157,9 +3111,7 @@ vect_recog_mixed_size_cond_pattern (vec< *type_in = vecitype; *type_out = vectype; - if (dump_enabled_p ()) - dump_printf_loc (MSG_NOTE, vect_location, - "vect_recog_mixed_size_cond_pattern: detected:\n"); + vect_pattern_detected ("vect_recog_mixed_size_cond_pattern", last_stmt); return pattern_stmt; } @@ -3729,9 +3681,7 @@ vect_recog_bool_pattern (vec * *type_out = vectype; *type_in = vectype; stmts->safe_push (last_stmt); - if (dump_enabled_p ()) - dump_printf_loc (MSG_NOTE, vect_location, - "vect_recog_bool_pattern: detected:\n"); + vect_pattern_detected ("vect_recog_bool_pattern", last_stmt); return pattern_stmt; } @@ -3770,9 +3720,7 @@ vect_recog_bool_pattern (vec * *type_out = vectype; *type_in = vectype; stmts->safe_push (last_stmt); - if (dump_enabled_p ()) - dump_printf_loc (MSG_NOTE, vect_location, - "vect_recog_bool_pattern: detected:\n"); + vect_pattern_detected ("vect_recog_bool_pattern", last_stmt); return pattern_stmt; } @@ -3829,9 +3777,8 @@ vect_recog_bool_pattern (vec * *type_out = vectype; *type_in = vectype; stmts->safe_push (last_stmt); - if (dump_enabled_p ()) - dump_printf_loc (MSG_NOTE, vect_location, - "vect_recog_bool_pattern: detected:\n"); + vect_pattern_detected ("vect_recog_bool_pattern", last_stmt); + return pattern_stmt; } else @@ -3966,9 +3913,7 @@ vect_recog_mask_conversion_pattern (vec< *type_out = vectype1; *type_in = vectype1; stmts->safe_push (last_stmt); - if (dump_enabled_p ()) - dump_printf_loc (MSG_NOTE, vect_location, - "vect_recog_mask_conversion_pattern: detected:\n"); + vect_pattern_detected ("vect_recog_mask_conversion_pattern", last_stmt); return pattern_stmt; } @@ -4092,9 +4037,7 @@ vect_recog_mask_conversion_pattern (vec< *type_out = vectype1; *type_in = vectype1; stmts->safe_push (last_stmt); - if (dump_enabled_p ()) - dump_printf_loc (MSG_NOTE, vect_location, - "vect_recog_mask_conversion_pattern: detected:\n"); + vect_pattern_detected ("vect_recog_mask_conversion_pattern", last_stmt); return pattern_stmt; } @@ -4140,9 +4083,7 @@ vect_recog_mask_conversion_pattern (vec< *type_out = vectype1; *type_in = vectype1; stmts->safe_push (last_stmt); - if (dump_enabled_p ()) - dump_printf_loc (MSG_NOTE, vect_location, - "vect_recog_mask_conversion_pattern: detected:\n"); + vect_pattern_detected ("vect_recog_mask_conversion_pattern", last_stmt); return pattern_stmt; } @@ -4324,10 +4265,7 @@ vect_try_gather_scatter_pattern (gimple tree vectype = STMT_VINFO_VECTYPE (stmt_info); *type_out = vectype; *type_in = vectype; - - if (dump_enabled_p ()) - dump_printf_loc (MSG_NOTE, vect_location, - "gather/scatter pattern detected:\n"); + vect_pattern_detected ("gather/scatter pattern", stmt); return pattern_stmt; }