X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Fopt_osr.h;h=24548587c171afc2e2a8980b8c8d188b944cb84d;hb=affef0ddb225a07fa6ecfd282ee83de62df43944;hp=1e0f2efbab9be267bd945fc9f554d5700f5b5542;hpb=754f75ba7836c706b5360afbb30e84cd14d59317;p=libfirm diff --git a/ir/opt/opt_osr.h b/ir/opt/opt_osr.h index 1e0f2efba..24548587c 100644 --- a/ir/opt/opt_osr.h +++ b/ir/opt/opt_osr.h @@ -15,14 +15,18 @@ #include "firm_types.h" -enum osr_flags { +/** Possible flags for the Operator Scalar Replacement. */ +typedef enum osr_flags { osr_flag_none = 0, /**< no additional flags */ - osr_flag_lftr_with_ov_check = 1, /**< do only linear function test replacement - if no overflow occurs. */ - /** default setting */ - osr_flag_default = osr_flag_lftr_with_ov_check + osr_flag_lftr_with_ov_check = 1, /**< do linear function test replacement + only if no overflow can occur. */ } osr_flags; +/* FirmJNI cannot handle identical enum values... */ + +/** default setting */ +#define osr_flag_default osr_flag_lftr_with_ov_check + /** * Do the Operator Scalar Replacement optimization and linear * function test replacement for loop control. @@ -33,7 +37,7 @@ enum osr_flags { * The linear function replacement test is controlled by the flags. * If the osr_flag_lftr_with_ov_check is set, the replacement is only * done if do overflow can occur. - * Otherwise it is ALWAYS done which might be unsure. + * Otherwise it is ALWAYS done which might be insecure. * * For instance: * @@ -53,8 +57,31 @@ enum osr_flags { * * because of overflow. * + * More bad cases: + * + * for (i = 0; i <= 0xF; ++i) + * + * will NOT be transformed into + * + * for (i = 0xFFFFFFF0; i <= 0xFFFFFFFF; ++i) + * + * although here is no direct overflow. The OV occurs when the ++i + * is executed (and would created an endless loop here!). + * + * For the same reason, a loop + * + * for (i = 0; i <= 9; i += x) + * + * will NOT be transformed because we cannot estimate whether an overflow + * might happen adding x. + * * Note that i < a + 400 is also not possible with the current implementation * although this might be allowed by other compilers... + * + * Note further that tests for equality can be handled some simplier (but are not + * implemented yet). + * + * This algorithm destoyes the link field of nodes. */ void opt_osr(ir_graph *irg, unsigned flags);