Author: rramanar Date: 2010-12-03 08:04:25 -0500 (Fri, 03 Dec 2010) New Revision: 3415
Modified: trunk/MAINTAINERS trunk/osprey/common/com/wn_simp.cxx trunk/osprey/common/com/wn_simp_code.h trunk/osprey/common/com/wn_simp_ftable.h Log: This is a fix for a recent regression which is seen with virtual destructors. The issue is that we are not removing dead code (and unreachable code) in WOPT in case the if-test contains EXTRACT_BITS. So we are introducing a simp_node function that bypasses EXTRACT_BITS when it is extracting the last bit of a Boolean constant. This plugs in to the simp_node framework and further simplifications are also possible, in the future. The assembly with and without the patch are given below for the following test case. Please look at the destructor functions: _ZN9TestClassD1Ev, _ZN9TestClassD2Ev for the dead code. Test case: class TestClass { virtual ~TestClass(); }; TestClass::~TestClass() { } Asm with fix: _ZN9TestClassD1Ev: # 0x10 # .frame %rsp, 24, %rsp .LBB1__ZN9TestClassD1Ev: movq $(_ZTV9TestClass+16),%rax # [0] _ZTV9TestClass+16 movq %rax,0(%rdi) # [1] id:7 .loc 1 10 0 # 9 { # 10 } ret # [1] .LDWend__ZN9TestClassD1Ev: Asm without the fix: tClassD1Ev: # 0x1c # .frame %rsp, 24, %rsp .loc 1 8 0 .LBB1__ZN9TestClassD1Ev: addq $-24,%rsp # [0] xorl %esi,%esi # [0] movq $(_ZTV9TestClass+16),%rax # [1] _ZTV9TestClass+16 .loc 1 10 0 testl $1,%esi # [1] .loc 1 8 0 movq %rax,0(%rdi) # [2] id:7 .loc 1 10 0 jne .LBB2__ZN9TestClassD1Ev # [2] .Lt_1_1282: addq $24,%rsp # [0] ret # [0] .p2align 5,,31 .LBB2__ZN9TestClassD1Ev: call _ZdlPv # [0] _ZdlPv .LBB4__ZN9TestClassD1Ev: jmp .Lt_1_1282 # [0] .LDWend__ZN9TestClassD1Ev: Modified: trunk/MAINTAINERS =================================================================== --- trunk/MAINTAINERS 2010-12-03 00:00:15 UTC (rev 3414) +++ trunk/MAINTAINERS 2010-12-03 13:04:25 UTC (rev 3415) @@ -77,6 +77,7 @@ Lianjie Luo luolianjie(AT)gmail.com Lin Ma lin.ma(AT)simplnano.com Mike Murphy mmurphy(AT)nvidia.com +Ram Ramanarayanan ramshankar.ramanaraya...@amd.com Jürgen Ributzka ributzka(AT)gmail.com Akella V.S. Sastry akella.sastry(AT)hp.com Robert Scollard robert.scollard(AT)amd.com Modified: trunk/osprey/common/com/wn_simp.cxx =================================================================== --- trunk/osprey/common/com/wn_simp.cxx 2010-12-03 00:00:15 UTC (rev 3414) +++ trunk/osprey/common/com/wn_simp.cxx 2010-12-03 13:04:25 UTC (rev 3415) @@ -388,10 +388,14 @@ k0 = WN_kid0(t); if (WN_operator(t) != OPR_CVTL) { + if (WN_operator(t) == OPR_EXTRACT_BITS) { + r = WN_SimplifyExp1(op,t); + } else { # if defined (KEY) && defined (Is_True_On) - if (Enable_WN_Simp_Expr_Limit == -1 || (Enable_WN_Simp_Expr_Limit != -1 && cur_idx < Enable_WN_Simp_Expr_Limit)) + if (Enable_WN_Simp_Expr_Limit == -1 || (Enable_WN_Simp_Expr_Limit != -1 && cur_idx < Enable_WN_Simp_Expr_Limit)) # endif - r = WN_SimplifyExp1(op, k0); + r = WN_SimplifyExp1(op, k0); + } } else { # if defined (KEY) && defined (Is_True_On) if (Enable_WN_Simp_Expr_Limit == -1 || (Enable_WN_Simp_Expr_Limit != -1 && cur_idx < Enable_WN_Simp_Expr_Limit)) Modified: trunk/osprey/common/com/wn_simp_code.h =================================================================== --- trunk/osprey/common/com/wn_simp_code.h 2010-12-03 00:00:15 UTC (rev 3414) +++ trunk/osprey/common/com/wn_simp_code.h 2010-12-03 13:04:25 UTC (rev 3415) @@ -1408,7 +1408,35 @@ /**************************************************************************/ /**************************************************************************/ /**************************************************************************/ +/*------------------------------------------------ + Simplifications for EXTRACT_BITS: + EXTRACT_BITS(INTCONSTANT,size=1,offset=0) +-------------------------------------------------*/ +simpnode simp_extract_bits (OPCODE opc, simpnode t, simpnode kx, + BOOL tconst, BOOL kxconst) { + if (SIMPNODE_operator(t) != OPR_EXTRACT_BITS) + return NULL; + OPCODE t_op, k0_op; + TYPE_ID ttyp, k0typ; + simpnode k0 = SIMPNODE_kid0(t); + t_op = SIMPNODE_opcode(t); + k0_op = SIMPNODE_opcode(k0); + + ttyp = OPCODE_rtype(t_op); + k0typ = OPCODE_rtype(k0_op); + + if (SIMPNODE_op_bit_offset(t) == 0 && SIMPNODE_op_bit_size(t) == 1) { + if (SIMPNODE_operator(k0) == OPR_INTCONST) { + if (SIMPNODE_const_val(k0) == 0 || SIMPNODE_const_val(k0) == 1) { + // We want to catch booleans + return k0; + } + } + } + return NULL; +} + /*------------------------------------------------ Simplifications for ABS: ABS(ABS(x)) ABS(X) Modified: trunk/osprey/common/com/wn_simp_ftable.h =================================================================== --- trunk/osprey/common/com/wn_simp_ftable.h 2010-12-03 00:00:15 UTC (rev 3414) +++ trunk/osprey/common/com/wn_simp_ftable.h 2010-12-03 13:04:25 UTC (rev 3415) @@ -185,7 +185,7 @@ NULL, /* OPR_RROTATE */ NULL, /* OPR_LDA_LABEL */ NULL, /* OPR_GOTO_OUTER_BLOCK */ -NULL, /* OPR_EXTRACT_BITS */ +simp_extract_bits, /* OPR_EXTRACT_BITS */ NULL, /* OPR_COMPOSE_BITS */ #endif #ifdef TARG_X8664 ------------------------------------------------------------------------------ Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev _______________________________________________ Open64-devel mailing list Open64-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/open64-devel