From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5551 invoked by alias); 8 Oct 2011 12:22:01 -0000 Received: (qmail 5538 invoked by uid 22791); 8 Oct 2011 12:22:00 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 08 Oct 2011 12:21:46 +0000 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/50661] std::equal should use more efficient version for arrays of pointers Date: Sat, 08 Oct 2011 12:22:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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 X-SW-Source: 2011-10/txt/msg00583.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50661 --- Comment #11 from Jakub Jelinek 2011-10-08 12:20:34 UTC --- One possibility would be some fallthru hint to the compiler similar to __builtin_assume_aligned that would tell the compiler that certain range of bytes will not trap/fault on reading and thus it is safe to read it speculatively. ptr = __builtin_assume_object_size (ptr, length); or similar. You could just insert it before the loop and let it be vectorized. But I believe we don't vectorize even void *array1[1024], *array2[1024]; int foo (void) { int i; for (i = 0; i < 1024; i++) if (array1[i] != array2[i]) break; return i == n; } where the will not fault/trap for i 0 .. 1023 is already known (or can be known).