From patchwork Tue Apr 15 01:59:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Ye X-Patchwork-Id: 339132 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6F49B14008F for ; Tue, 15 Apr 2014 11:59:57 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=gwL3xFe5qeLvl98q //cR2ARqOMH6MlfMB31whkVPHz0CP51SDpdK4ssvhpTLHJ2vB/1KXAoKZuM/+/f+ Y/AlZIeugxeJUDpn+rGOJtyuMwlxA+45YIhW7rxI9SLfUApzzWSjyLCMHN1yOsXS TTGe+qKeu5FppgCCVHRaY1bJM4U= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=6LUy+wGGPcAqp/PwEYF+O/ UlZEY=; b=iH2fPf95qpnyzdi6lfiy9eukwSo5+sD/hK7P3wn1356sGM/ucVquyy G52Gq0XNQU9yb3DFP58/p1k/NVlz7wEgJ2188GY8z6Fa5gEDwaFlGRGF5d7hFBj1 iA7XjBp+CuhaFzAgoikx8jBHgqzaRo8wKb6Pr/WxEfrjKE+gK//Ko= Received: (qmail 31821 invoked by alias); 15 Apr 2014 01:59:49 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 31589 invoked by uid 89); 15 Apr 2014 01:59:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 15 Apr 2014 01:59:43 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Tue, 15 Apr 2014 02:59:41 +0100 Received: from SHAWIN205 ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 15 Apr 2014 02:59:55 +0100 From: "Joey Ye" To: Subject: [patch] Disable if_conversion2 for Og Date: Tue, 15 Apr 2014 09:59:52 +0800 Message-ID: <000001cf584e$66102060$32306120$@arm.com> MIME-Version: 1.0 X-MC-Unique: 114041502594100201 If-converstion is harmful to optimized debugging as it generates conditional execution instructions with line number information, which resulted in a dillusion to developers that both then-else branches are executed. For example: test.c: 1: unsigned oldest_sequence; 2: 3: unsigned foo(unsigned seq_number) 4: { 5: if ((seq_number + 5) < 10) 6: seq_number += 100; 7: else 8: seq_number = oldest_sequence; if (seq_number < oldest_sequence) seq_number = oldest_sequence; return seq_number; } $ arm-none-eabi-gcc -mthumb -mcpu=cortex-m3 -Og -g3 gets: .loc 1 5 0 adds r3, r0, #5 cmp r3, #9 .loc 1 6 0 <----- line 6, then branch itee ls addls r0, r0, #100 .LVL1: .loc 1 8 0 <----- line 8, else branch. Both branches seems to be executed in GDB ldrhi r3, .L5 ldrhi r0, [r3] The reason is that if_conversion2 is still enabled in Og. The patch simply disables it for Og. Tests: * -Og bootstrap passed. * Make check default (no additional option): No regression. * Make check with -Og: expected regressions. Cases relying on if-conversion2 failed. > FAIL: gcc.target/arm/its.c scan-assembler-times \\tit 2 > FAIL: gcc.target/arm/pr40956.c scan-assembler-times mov[\\\\t ]*r., #0 1 > FAIL: gcc.target/arm/thumb-ifcvt-2.c scan-assembler asreq > FAIL: gcc.target/arm/thumb-ifcvt-2.c scan-assembler lslne > FAIL: gcc.target/arm/thumb-ifcvt.c scan-assembler asrne > FAIL: gcc.target/arm/thumb-ifcvt.c scan-assembler lslne OK to trunk and 4.8/4.9 branch? ChangeLog: * opts.c (OPT_fif_conversion2): Disable for Og. { OPT_LEVELS_1_PLUS, OPT_fipa_profile, NULL, 1 }, diff --git a/gcc/opts.c b/gcc/opts.c index fdc903f..e076253 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -432,7 +432,7 @@ static const struct default_options default_options_table[] = { OPT_LEVELS_1_PLUS, OPT_fcprop_registers, NULL, 1 }, { OPT_LEVELS_1_PLUS, OPT_fforward_propagate, NULL, 1 }, { OPT_LEVELS_1_PLUS, OPT_fif_conversion, NULL, 1 }, - { OPT_LEVELS_1_PLUS, OPT_fif_conversion2, NULL, 1 }, + { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fif_conversion2, NULL, 1 }, { OPT_LEVELS_1_PLUS, OPT_fipa_pure_const, NULL, 1 }, { OPT_LEVELS_1_PLUS, OPT_fipa_reference, NULL, 1 },