From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1857 invoked by alias); 3 Oct 2006 16:04:03 -0000 Received: (qmail 1837 invoked by uid 48); 3 Oct 2006 16:03:55 -0000 Date: Tue, 03 Oct 2006 16:04:00 -0000 Subject: [Bug tree-optimization/29333] New: Generation of MAX_EXPRs and MIN_EXPRs missed by phiopt X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "roberto dot costa at st dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-10/txt/msg00231.txt.bz2 List-Id: There are cases in which phiopt doesn't recognize MAX_EXPRs or MIN_EXPRs patterns. In particular, source codes that look very similar at first sight may induce phiopt to behave differently. Let's consider the following two functions: ----------------------------- int minmax_correct(int a) { if (a > 32767) a = 32767; else if (a < -32768) a = -32768; return a; } int minmax_wrong(int a) { if (a > 32767) a = 32767; if (a < -32768) a = -32768; return a; } ----------------------------- MIN_EXPRs and MAX_EXPRs are generated for the first function, but not for the second. Here is the contents of trace file minmax.c.042t.phicprop1: ----------------------------- ;; Function minmax_correct (minmax_correct) minmax_correct (a) { : if (a_2 > 32767) goto ; else goto ; :; if (a_2 < -32768) goto ; else goto ; :; # a_1 = PHI <32767(2), a_2(3), -32768(4)>; :; = a_1; return ; } ;; Function minmax_wrong (minmax_wrong) Removing basic block 6 minmax_wrong (a) { : if (a_3 > 32767) goto ; else goto ; :; if (a_3 < -32768) goto ; else goto ; # a_9 = PHI ; :; # a_2 = PHI ; :; = a_2; return ; } ----------------------------- And here is minmax.c.043t.phiopt1: ----------------------------- ;; Function minmax_correct (minmax_correct) Removing basic block 4 Removing basic block 3 Merging blocks 2 and 5 minmax_correct (a) { : a_7 = MAX_EXPR <-32768, a_2>; a_8 = MIN_EXPR ; = a_8; return ; } ;; Function minmax_wrong (minmax_wrong) minmax_wrong (a) { : if (a_3 > 32767) goto ; else goto ; :; if (a_3 < -32768) goto ; else goto ; # a_9 = PHI ; :; # a_2 = PHI ; :; = a_2; return ; } ----------------------------- -- Summary: Generation of MAX_EXPRs and MIN_EXPRs missed by phiopt Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: roberto dot costa at st dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29333