From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24149 invoked by alias); 13 Feb 2014 08:16:11 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 24136 invoked by uid 89); 13 Feb 2014 08:16:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-bk0-f47.google.com Received: from mail-bk0-f47.google.com (HELO mail-bk0-f47.google.com) (209.85.214.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 13 Feb 2014 08:16:08 +0000 Received: by mail-bk0-f47.google.com with SMTP id d7so2955976bkh.20 for ; Thu, 13 Feb 2014 00:16:05 -0800 (PST) X-Received: by 10.204.165.206 with SMTP id j14mr39363bky.45.1392279365114; Thu, 13 Feb 2014 00:16:05 -0800 (PST) Received: from [192.168.178.20] (p5495A19C.dip0.t-ipconnect.de. [84.149.161.156]) by mx.google.com with ESMTPSA id o11sm1260365bkg.13.2014.02.13.00.16.04 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 13 Feb 2014 00:16:04 -0800 (PST) User-Agent: K-9 Mail for Android In-Reply-To: <52FC6F24.9010105@ceis.cujae.edu.cu> References: <52FC6F24.9010105@ceis.cujae.edu.cu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Subject: Re: Dead code elimination PROBLEM From: Richard Biener Date: Thu, 13 Feb 2014 08:16:00 -0000 To: chronicle ,gcc@gcc.gnu.org Message-ID: <7d0fddb5-d0aa-404c-8337-d1a46dae5c99@email.android.com> X-IsSubscribed: yes X-SW-Source: 2014-02/txt/msg00174.txt.bz2 On February 13, 2014 8:07:16 AM GMT+01:00, chronicle wrote: >Hi PPL i developed a plugin that produces the following gimple > >test () >{ > int selected_fnc_var_.3; > int random_Var.2; > int D.2363; > int _1; > > : > random_Var.2_2 = rand (); > selected_fnc_var_.3_3 = random_Var.2_2 %[fl] 5; > if (selected_fnc_var_.3_3 == 4) goto ; > if (selected_fnc_var_.3_3 == 3) goto ; > if (selected_fnc_var_.3_3 == 2) goto ; > if (selected_fnc_var_.3_3 == 1) goto ; > if (selected_fnc_var_.3_3 == 0) goto ; >: > _1 = f.clone.4 ("t", "t"); > goto ; >: > _1 = f.clone.3 ("t", "t"); > goto ; >: > _1 = f.clone.2 ("t", "t"); > goto ; >: > _1 =f.clone.1 ("t", "t"); > goto ; > >: You miss a phi node merging the different _1. Also you cannot assign to _1 multiple times but have to use a new ssa name for each. Richard. > if (_1 != 0) > goto ; > else > goto ; > > : > __builtin_puts (&" f success "[0]); > goto ; > > : > __builtin_puts (&" f failed "[0]); > > : > return; > >} > >with this final code > >00000000004005c6 : > 4005c6: 55 push %rbp > 4005c7: 48 89 e5 mov %rsp,%rbp > 4005ca: 53 push %rbx > 4005cb: 48 83 ec 08 sub $0x8,%rsp > 4005cf: e8 6c fe ff ff callq 400440 > 4005d4: 89 d9 mov %ebx,%ecx > 4005d6: c1 f9 1f sar $0x1f,%ecx > 4005d9: 89 d8 mov %ebx,%eax > 4005db: 31 c8 xor %ecx,%eax > 4005dd: ba 67 66 66 66 mov $0x66666667,%edx > 4005e2: f7 e2 mul %edx > 4005e4: 89 d0 mov %edx,%eax > 4005e6: d1 e8 shr %eax > 4005e8: 31 c8 xor %ecx,%eax > 4005ea: 89 c2 mov %eax,%edx > 4005ec: c1 e2 02 shl $0x2,%edx > 4005ef: 01 c2 add %eax,%edx > 4005f1: 89 d8 mov %ebx,%eax > 4005f3: 29 d0 sub %edx,%eax > 4005f5: 83 f8 04 cmp $0x4,%eax > 4005f8: 75 32 jne 40062c > 4005fa: 83 f8 03 cmp $0x3,%eax > 4005fd: 74 2d je 40062c > 4005ff: 83 f8 02 cmp $0x2,%eax > 400602: 74 28 je 40062c > 400604: 83 f8 01 cmp $0x1,%eax > 400607: 74 23 je 40062c > 400609: 85 c0 test %eax,%eax > 40060b: 74 1f je 40062c > 40060d: be bc 09 40 00 mov $0x4009bc,%esi > 400612: bf c6 09 40 00 mov $0x4009c6,%edi > 400617: e8 7d 02 00 00 callq 400899 > 40061c: 85 c0 test %eax,%eax > 40061e: 75 0c jne 40062c > 400620: bf d0 09 40 00 mov $0x4009d0,%edi > 400625: e8 e6 fd ff ff callq 400410 > 40062a: eb 0a jmp 400636 > 40062c: bf e8 09 40 00 mov $0x4009e8,%edi > 400631: e8 da fd ff ff callq 400410 > 400636: 48 83 c4 08 add $0x8,%rsp > 40063a: 5b pop %rbx > 40063b: 5d pop %rbp > 40063c: c3 retq > > >from this gimple > >test(){ > >int D.2363; > int _1; > > : > _1 = f("t", "t"); > if (_1 != 0) > goto ; > else > goto ; > > : > __builtin_puts (&" f "[0]); > goto ; > > : > __builtin_puts (&" f "[0]); > > : > return; >} > >as you can see in the dis output code, its only make call to f.clone.4 >( callq 400899 ), i suppose is the dead code elimination >pass is the responsable of this action, i tryed to disable it using -O0 > >compilation option but without success. my question is how can i make >the compiler produce the final code without deleting those dead codes >portion ( do i need to make any kind of PHI nodes in the labels to >achive that, if so how could i do that ? ) > >thanks in advance