From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 110898 invoked by alias); 25 May 2015 17:17:20 -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 110847 invoked by uid 48); 25 May 2015 17:17:16 -0000 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/66278] Missed auto-vectorization of an array subtraction Date: Mon, 25 May 2015 17:17: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.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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: cc 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: 2015-05/txt/msg02068.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66278 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #1 from Jakub Jelinek --- Seems to be overly conservative tree-chrec.c code. chrec_fold_plus is called on (sizetype) {i_5, +, 1}_1 and 30906 where loop->nb_iterations_upper_bound is 100 and loop->nb_iterations is (unsigned int) _4 + 1 <= 101 ? 100 - (unsigned int) _4 : 0 It is a pitty we don't use range info on _4 when simplifying loop->nb_iterations, here it is [0, 1], so we could at least easily find out that (unsigned int) _4 + 1 <= 101 is always true. Anyway, chrec_fold_plus just gives up on: CASE_CONVERT: if (tree_contains_chrecs (op0, NULL)) return chrec_dont_know; eventhough from the loop bounds in this case it could prove that for all loop iterations the chrec always fits into the narrower type, including the addition and thus it can safely move the addition into the chrec's op0. If I change [3][3] to [0][0], then the problem is in chrec_fold_multiply instead (again, we have (sizetype) i_16 * 4 and give up because of the cast). If the testcase is modified, so that it uses unsigned long as i and next type, then it is vectorized fine.