From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19576 invoked by alias); 6 Oct 2014 11:27:49 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 19518 invoked by uid 48); 6 Oct 2014 11:27:45 -0000 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/63464] compare one character to many: faster Date: Mon, 06 Oct 2014 11:27:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on cc everconfirmed Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-10/txt/msg00374.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63464 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2014-10-06 CC| |jakub at gcc dot gnu.org, | |rguenth at gcc dot gnu.org, | |steven at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Jakub Jelinek --- We have this optimization implemented for switches, if you compile char*f3(char*s){ do { switch (*s) { case ' ': case ',': case '\r': case '\n': ++s; continue; default: return s; } } while (1); } then it will do the bit test, see r189173 (and various follow-up fixes for that). Now, we can argue whether in this case it is beneficial to perform the MINUS_EXPR or if maxval is small enough (e.g. when maxval is smaller than BITS_PER_WORD), just assume minval is 0. And then the question is, if we should teach reassoc range optimizations to reuse emit_case_bit_tests, or convert such tests into a GIMPLE_SWITCH and expand as such. Richard/Steven, thoughts about this?