From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31491 invoked by alias); 3 Aug 2011 12:25:51 -0000 Received: (qmail 31475 invoked by uid 22791); 3 Aug 2011 12:25:50 -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; Wed, 03 Aug 2011 12:25:36 +0000 From: "enkovich.gnu at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/49959] New: ABS pattern is not recognized X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: enkovich.gnu at gmail 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-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Wed, 03 Aug 2011 12:25:00 -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 X-SW-Source: 2011-08/txt/msg00353.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49959 Summary: ABS pattern is not recognized Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned@gcc.gnu.org ReportedBy: enkovich.gnu@gmail.com Created attachment 24900 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24900 Simple test where ABS pattern is not recognized Here is optimization opportunity for ABS pattern recognizer which does not catch all cases. Here is a simple test for ABS computation: #define ABS(X) (((X)>0)?(X):-(X)) int test_abs(int *cur) { unsigned long sad = 0; sad = ABS(cur[0]); return sad; } GIMPLE for the test is good (phase optimized): test_abs (int * cur) { int D.2783; int D.2782; : D.2782_3 = *cur_2(D); D.2783_4 = ABS_EXPR ; return D.2783_4; } Now try to make a minor change in test: #define ABS(X) (((X)>0)?(X):-(X)) int test_abs(int *cur) { unsigned long sad = 0; sad += ABS(cur[0]); return sad; } GIMPLE becomes worse: test_abs (int * cur) { int D.2788; int D.2787; int D.2783; long unsigned int iftmp.0; : D.2783_4 = *cur_3(D); if (D.2783_4 > 0) goto ; else goto ; : iftmp.0_6 = (long unsigned int) D.2783_4; goto ; : D.2787_8 = -D.2783_4; iftmp.0_9 = (long unsigned int) D.2787_8; : # iftmp.0_1 = PHI D.2788_11 = (int) iftmp.0_1; return D.2788_11; } Compiler used for tests: Target: x86_64-unknown-linux-gnu Configured with: ../gcc/configure --prefix=/export/gcc-build --enable-languages=c,c++,fortran Thread model: posix gcc version 4.7.0 20110707 (experimental) (GCC) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-O2' '-S' '-mtune=generic' '-march=x86-64'