From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3036 invoked by alias); 29 Jul 2014 16:04:50 -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 31154 invoked by uid 48); 29 Jul 2014 15:31:00 -0000 From: "alan.lawrence at arm dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/61114] Scalar evolution hides a big-endian const-folding bug. Date: Tue, 29 Jul 2014 16:04: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: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: alan.lawrence at arm dot com X-Bugzilla-Status: UNCONFIRMED 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: 2014-07/txt/msg01922.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61114 Alan Lawrence changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |alan.lawrence at arm dot com --- Comment #8 from Alan Lawrence --- Here's a simpler testcase that shows the "if (BYTES_BIG_ENDIAN)" in tree-vect-loop.c is wrong: static unsigned char in[16]; int main ( unsigned char argc, char **argv) { unsigned char i = 0; unsigned char sum = 0; for (i = 0; i < 16; i++) in[i] = i; for (i = 0; i < 16; i++) sum += in[i]; if (sum != (unsigned char) 120) __builtin_printf ("Failed\n"); } On AArch64 or x86, compiling with -O3, there is no output. On AArch64_be or PowerPC (compiling with -O3 -maltivec), it prints "Failed!". The output from dom2 shows the problem: Optimizing statement vect_sum_13.10_27 = [reduc_plus_expr] vect_sum_13.8_4; Replaced 'vect_sum_13.8_4' with constant '{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }' Folded to: vect_sum_13.10_27 = { 120, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; LKUP STMT vect_sum_13.10_27 = { 120, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } vect_sum_13.10_27 = { 120, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; ==== ASGN vect_sum_13.10_27 = { 120, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } Optimizing statement stmp_sum_13.9_28 = BIT_FIELD_REF ; Replaced 'vect_sum_13.10_27' with constant '{ 120, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }' Folded to: stmp_sum_13.9_28 = 0; LKUP STMT stmp_sum_13.9_28 = 0 stmp_sum_13.9_28 = 0; ==== ASGN stmp_sum_13.9_28 = 0 Optimizing statement vect_sum_13.11_29 = stmp_sum_13.9_28; Replaced 'stmp_sum_13.9_28' with constant '0' LKUP STMT vect_sum_13.11_29 = 0 vect_sum_13.11_29 = 0; ==== ASGN vect_sum_13.11_29 = 0 Optimizing statement if (vect_sum_13.11_29 != 120) Replaced 'vect_sum_13.11_29' with constant '0' Folded to: if (1 != 0)