|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Ping: Switch initializations conversion
+ info.index_expr = SWITCH_CND (swtch);
+ index_type = TREE_TYPE (info.index_expr); The use of the SWITCH_CND's type as the index type is problematic in Ada (and maybe in other languages) because it badly interacts with the optimization in tree-ssa-forwprop.c that gobbles casts within SWITCH_CND and you may end up doing arithmetics in the wrong type. Ada testcase attached, compile with "gcc -c p.adb". + BUG | 4.4.0 20080704 (experimental) [trunk revision 137450] (i586-suse-linux-gnu) GCC error:| | in set_value_range, at tree-vrp.c:379 | | Error detected around p.adb:12 In .028t.ccp: op_kind.0_7 = (q__internal_element_kinds) op_kind_2(D); switch (op_kind.0_7) { case 244: goto <L4>; case 246: goto <L3>; default : goto <L5>; } op_kind is , which is an subtype (you cannot do arithmetics in it), so it is converted to the base type q__internal_element_kinds before the switch. In 029t.forwprop1 the conversion is removed: op_kind.0_7 = (q__internal_element_kinds) op_kind_2(D); switch (op_kind_2(D)) { case 244: goto <L4>; case 246: goto <L3>; default : goto <L5>; } Then in 040t.switchconv arithmetics in the subtype is created: csui.6_8 = op_kind_2(D); csui.6_7 = csui.6_8 - 244; if (csui.6_7 <= 2) goto <bb 10(<L10>); else goto <bb 9(<L9>); which doesn't make sense since the range of the subtype in [226; 246] and ultimately leads to the VRP failure because it deduces the [226;2] range for the first branch of the condition. It seems to me that, since the pass generates new arithmetics for the SWITCH_EXPR, it should do it in the SWITCH_EXPR's type and the condition be converted back to it if necessary. What do you think? Thanks in advance. -- Eric Botcazou |
![]() |
| Viewing: Web Development Archives > Mailing Lists > Development > Ping: Switch initializations conversion |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|