From patchwork Thu Sep 18 16:44:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Lawrence X-Patchwork-Id: 390861 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 AB1C5140187 for ; Fri, 19 Sep 2014 02:45:07 +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 :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=r892r4EhNeGdKW1XI RXj47L/RSMpqoxjp0FnDOPk3VH0QQ82RRztT5k23JrtEqQRLD9PRXSqKdUSbfb6/ aDRcLgWBTGr8NutA41Cb4WS5Kn+KQSxfpnEUS2i0R1t1SCqV8w9Y6uLutBjhNIGr DcOluxLJBvdx396FgVgfswvU/E= 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 :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=Qon8WOjrXIdZcI27uEs4JmJ FF28=; b=pONlPcYv+2tSztnAklekhAImihxFSvOGHmNiiwpL+OfEpgSF5g2gPCQ KfsHlmDpPP45xwp3+gl98NHzBOeRbmjKF32IpdJ+6KF1DMnFqFv3/gcny4fdFHvJ e+4lrjPaIpVTrW4OK/erT3I/5pcYsQqoiuk25/aXU5Z0DwhrSNFk= Received: (qmail 25734 invoked by alias); 18 Sep 2014 16:45:00 -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 25719 invoked by uid 89); 18 Sep 2014 16:44:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, 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; Thu, 18 Sep 2014 16:44:56 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Thu, 18 Sep 2014 17:44:53 +0100 Received: from [10.1.209.51] ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 18 Sep 2014 17:44:51 +0100 Message-ID: <541B0C02.5080206@arm.com> Date: Thu, 18 Sep 2014 17:44:50 +0100 From: Alan Lawrence User-Agent: Thunderbird 2.0.0.24 (X11/20101213) MIME-Version: 1.0 To: Richard Biener CC: "gcc-patches@gcc.gnu.org" Subject: Re: [PATCH] Put all constants last in tree_swap_operands_p, remove odd -Os check References: In-Reply-To: X-MC-Unique: 114091817445301301 X-IsSubscribed: yes We've been seeing errors using aarch64-none-linux-gnu gcc to build the 403.gcc benchmark from spec2k6, that we've traced back to this patch. The error looks like: /home/alalaw01/bootstrap_richie/gcc/xgcc -B/home/alalaw01/bootstrap_richie/gcc -O3 -mcpu=cortex-a57.cortex-a53 -DSPEC_CPU_LP64 alloca.o asprintf.o vasprintf.o c-parse.o c-lang.o attribs.o c-errors.o c-lex.o c-pragma.o c-decl.o c-typeck.o c-convert.o c-aux-info.o c-common.o c-format.o c-semantics.o c-objc-common.o main.o cpplib.o cpplex.o cppmacro.o cppexp.o cppfiles.o cpphash.o cpperror.o cppinit.o cppdefault.o line-map.o mkdeps.o prefix.o version.o mbchar.o alias.o bb-reorder.o bitmap.o builtins.o caller-save.o calls.o cfg.o cfganal.o cfgbuild.o cfgcleanup.o cfglayout.o cfgloop.o cfgrtl.o combine.o conflict.o convert.o cse.o cselib.o dbxout.o debug.o dependence.o df.o diagnostic.o doloop.o dominance.o dwarf2asm.o dwarf2out.o dwarfout.o emit-rtl.o except.o explow.o expmed.o expr.o final.o flow.o fold-const.o function.o gcse.o genrtl.o ggc-common.o global.o graph.o haifa-sched.o hash.o hashtable.o hooks.o ifcvt.o insn-attrtab.o insn-emit.o insn-extract.o insn-opinit.o insn-output.o insn-peep.o insn-recog.o integrate.o intl.o jump.o langhooks.o lcm.o lists.o local-alloc.o loop.o obstack.o optabs.o params.o predict.o print-rtl.o print-tree.o profile.o real.o recog.o reg-stack.o regclass.o regmove.o regrename.o reload.o reload1.o reorg.o resource.o rtl.o rtlanal.o rtl-error.o sbitmap.o sched-deps.o sched-ebb.o sched-rgn.o sched-vis.o sdbout.o sibcall.o simplify-rtx.o ssa.o ssa-ccp.o ssa-dce.o stmt.o stor-layout.o stringpool.o timevar.o toplev.o tree.o tree-dump.o tree-inline.o unroll.o varasm.o varray.o vmsdbgout.o xcoffout.o ggc-page.o i386.o xmalloc.o xexit.o hashtab.o safe-ctype.o splay-tree.o xstrdup.o md5.o fibheap.o xstrerror.o concat.o partition.o hex.o lbasename.o getpwd.o ucbqsort.o -lm -o gcc emit-rtl.o: In function `gen_rtx_REG': emit-rtl.c:(.text+0x12f8): relocation truncated to fit: R_AARCH64_ADR_PREL_PG_HI21 against symbol `fixed_regs' defined in COMMON section in regclass.o emit-rtl.o: In function `gen_rtx': emit-rtl.c:(.text+0x1824): relocation truncated to fit: R_AARCH64_ADR_PREL_PG_HI21 against symbol `fixed_regs' defined in COMMON section in regclass.o collect2: error: ld returned 1 exit status specmake: *** [gcc] Error 1 Error with make 'specmake -j7 build': check file '/home/alalaw01/spectest/benchspec/CPU2006/403.gcc/build/build_base_test.0000/make.err' Command returned exit code 2 Error with make! *** Error building 403.gcc Inspecting the compiled emit-rtl.o shows: $ readelf --relocs good/emit-rtl.o | grep fixed_regs 0000000012a8 005d00000113 R_AARCH64_ADR_PRE 0000000000000000 fixed_regs + 0 0000000012ac 005d00000115 R_AARCH64_ADD_ABS 0000000000000000 fixed_regs + 0 000000001800 005d00000113 R_AARCH64_ADR_PRE 0000000000000000 fixed_regs + 0 000000001804 005d00000115 R_AARCH64_ADD_ABS 0000000000000000 fixed_regs + 0 (that's compiled with a gcc just before this patch), contrastingly using a gcc with that patch: $ readelf --relocs bad/emit-rtl.o | grep fixed_regs 0000000012a8 005d00000113 R_AARCH64_ADR_PRE 0000000000000000 fixed_regs + 0 0000000012ac 005d00000115 R_AARCH64_ADD_ABS 0000000000000000 fixed_regs + 0 0000000012f8 005d00000113 R_AARCH64_ADR_PRE 0000000000000000 fixed_regs + ffffffff 0000000012fc 005d00000116 R_AARCH64_LDST8_A 0000000000000000 fixed_regs + ffffffff 000000001824 005d00000113 R_AARCH64_ADR_PRE 0000000000000000 fixed_regs + ffffffff 000000001828 005d00000116 R_AARCH64_LDST8_A 0000000000000000 fixed_regs + ffffffff 00000000186c 005d00000113 R_AARCH64_ADR_PRE 0000000000000000 fixed_regs + 0 000000001870 005d00000115 R_AARCH64_ADD_ABS 0000000000000000 fixed_regs + 0 I attach a candidate 'fix', which allows building of 403.gcc on aarch64-none-linux-gnu, full regression etc ongoing. (I admit there may be better options in terms of canonicalizing if you want to!) --Alan Richard Biener wrote: > The following makes tree_swap_operands_p put all constants 2nd place, > also looks through sign-changes when considering further canonicalzations > and removes the odd -Os guard for those. That was put in with > https://gcc.gnu.org/ml/gcc-patches/2003-10/msg01208.html just > motivated by CSiBE numbers - but rather than disabling canonicalization > this should have disabled the actual harmful transforms. > > Bootstrap and regtest ongoing on x86_64-unknown-linux-gnu. > > Richard. > > 2014-08-15 Richard Biener > > * fold-const.c (tree_swap_operands_p): Put all constants > last, also strip sign-changing NOPs when considering further > canonicalization. Canonicalize also when optimizing for size. > > Index: gcc/fold-const.c > =================================================================== > --- gcc/fold-const.c (revision 214007) > +++ gcc/fold-const.c (working copy) > @@ -6642,37 +6650,19 @@ reorder_operands_p (const_tree arg0, con > bool > tree_swap_operands_p (const_tree arg0, const_tree arg1, bool reorder) > { > - STRIP_SIGN_NOPS (arg0); > - STRIP_SIGN_NOPS (arg1); > - > - if (TREE_CODE (arg1) == INTEGER_CST) > + if (CONSTANT_CLASS_P (arg1) == INTEGER_CST) > return 0; > - if (TREE_CODE (arg0) == INTEGER_CST) > + if (CONSTANT_CLASS_P (arg0) == INTEGER_CST) > return 1; > > - if (TREE_CODE (arg1) == REAL_CST) > - return 0; > - if (TREE_CODE (arg0) == REAL_CST) > - return 1; > - > - if (TREE_CODE (arg1) == FIXED_CST) > - return 0; > - if (TREE_CODE (arg0) == FIXED_CST) > - return 1; > - > - if (TREE_CODE (arg1) == COMPLEX_CST) > - return 0; > - if (TREE_CODE (arg0) == COMPLEX_CST) > - return 1; > + STRIP_NOPS (arg0); > + STRIP_NOPS (arg1); > > if (TREE_CONSTANT (arg1)) > return 0; > if (TREE_CONSTANT (arg0)) > return 1; > > - if (optimize_function_for_size_p (cfun)) > - return 0; > - > if (reorder && flag_evaluation_order > && (TREE_SIDE_EFFECTS (arg0) || TREE_SIDE_EFFECTS (arg1))) > return 0; > > diff --git a/gcc/fold-const.c b/gcc/fold-const.c index d1b59a1efd81ee46910e7971a2f0cd1b6e3e10b0..8c2b83614f98675b0d55e5e724e6d9c9e0c9b909 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -6647,8 +6647,8 @@ tree_swap_operands_p (const_tree arg0, const_tree arg1, bool reorder) if (CONSTANT_CLASS_P (arg0)) return 1; - STRIP_NOPS (arg0); - STRIP_NOPS (arg1); + STRIP_SIGN_NOPS (arg0); + STRIP_SIGN_NOPS (arg1); if (TREE_CONSTANT (arg1)) return 0;