Author: zhuqing
Date: 2012-07-13 03:23:05 -0400 (Fri, 13 Jul 2012)
New Revision: 3973
Modified:
trunk/osprey/be/opt/opt_bdce.cxx
trunk/osprey/be/opt/opt_htable.cxx
Log:
Fix bug966. Assertion in cgexpand under m32 O2.
case:
typedef unsigned char uint8_t;
typedef unsigned int uint32_t;
typedef unsigned long long int uint64_t;
extern memddd(unsigned int);
void build_avp(uint32_t avp_vendor, uint64_t in_value_len)
{
if (avp_vendor != 0)
{
in_value_len = in_value_len +4;
}
{
memddd(in_value_len);
}
}
The assertion failure is triggered during Code_Expansion phase, when expanding
I8SELECT, the pair TN of its kid is null, so it hit the assertion. But the
whirl IR after WOPT phase was not correct, so the root cause should be in WOPT
phase. In SELECT, Both Kid 1 and Kid 2 must have res as the result type. For
ex, in above case, the Dtyp of kid 1 turn to U4 from U8 in BITWISE_DCE phase.
So the fix method here is to generate CVT for the kids to make sure their Dtyp
are the same with SELECT.
The patch handle following situations:
1) LDC I8 2) LDC U4 3) LDC U4 4) LDC U4 5)
LDC U4
LDC I8 LDC U4 LDC U4 LDC I8
LDC U4
I8SELECT U4SELECT I8SELECT I8SELECT
I4SELECT
for 1) and 2), it is of right form;
for 3) and 5), we will set the type of SELECT to U4;
for 4), I8U4CVT will be added for U4.
Author of this patch:Xiaojing-zhang
Code Review: Sun chan
Modified: trunk/osprey/be/opt/opt_bdce.cxx
===================================================================
--- trunk/osprey/be/opt/opt_bdce.cxx 2012-07-11 10:16:18 UTC (rev 3972)
+++ trunk/osprey/be/opt/opt_bdce.cxx 2012-07-13 07:23:05 UTC (rev 3973)
@@ -1381,8 +1381,25 @@
}
else new_cr->Set_opnd(i, cr->Opnd(i));
}
+ // Fix bug966: for SELECT, both Kid 1 and Kid 2 must have res as the
result type
+ opr = cr->Opr();
+ if (opr == OPR_SELECT) {
+ if (new_cr->Get_opnd(1)->Dtyp() != new_cr->Get_opnd(2)->Dtyp()) {
+ for (INT index = 1; index < new_cr->Kid_count(); index++) {
+ CODEREP *opnd = new_cr->Opnd(index);
+ if (new_cr->Dtyp() != opnd->Dtyp()) {
+ OPCODE opc = OPCODE_make_op(OPR_CVT, new_cr->Dtyp(),
opnd->Dtyp());
+ CODEREP *cvt_cr = Htable()->Add_unary_node(opc, opnd);
+ new_cr->Set_opnd(index, cvt_cr);
+ need_rehash = TRUE;
+ }
+ }
+ }
+ else {
+ new_cr->Set_dtyp(new_cr->Get_opnd(1)->Dtyp());
+ }
+ }
// check if current node can be deleted
- opr = cr->Opr();
if (opr == OPR_CVTL) {
if (((Livebits(cr) & ~Bitmask_of_size(cr->Offset())) == 0) ||
Redundant_cvtl(MTYPE_is_signed(cr->Dtyp()),
Modified: trunk/osprey/be/opt/opt_htable.cxx
===================================================================
--- trunk/osprey/be/opt/opt_htable.cxx 2012-07-11 10:16:18 UTC (rev 3972)
+++ trunk/osprey/be/opt/opt_htable.cxx 2012-07-13 07:23:05 UTC (rev 3973)
@@ -3737,6 +3737,21 @@
cr->Set_call_op_aux_id (WN_st_idx(wn));
break;
#endif
+ // Fix bug966: for SELECT, both Kid 1 and Kid 2 must have res as the
result type
+ case OPR_SELECT:
+ if (cr->Get_opnd(1)->Dtyp() != cr->Get_opnd(2)->Dtyp())
+ for ( INT index = 1; index < cr->Kid_count(); index++) {
+ CODEREP *opnd = cr->Opnd(index);
+ if (cr->Dtyp() != opnd->Dtyp()) {
+ OPCODE opc = OPCODE_make_op(OPR_CVT, cr->Dtyp(), opnd->Dtyp());
+ CODEREP *cvt_cr = Add_unary_node(opc, opnd);
+ cr->Set_opnd(index, cvt_cr);
+ }
+ }
+ else {
+ cr->Set_dtyp(cr->Get_opnd(1)->Dtyp());
+ }
+ break;
}
BOOL do_canonicalization = TRUE;
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Open64-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/open64-devel