+ ent_l = get_const_entity(left);
+ ent_r = get_const_entity(right);
+
+ if (ent_l != NULL && ent_r != NULL) {
+ /* both entities are const, try to evaluate */
+ irn = eval_strcmp(get_irn_irg(call), ent_l, ent_r, res_tp);
+ } else if (ent_l != NULL) {
+ if (is_empty_string(ent_l)) {
+ /* s strcmp("", s) ==> -(*s)*/
+ v = right;
+ goto replace_by_call;
+ }
+ } else if (ent_r != NULL) {
+ if (is_empty_string(ent_r)) {
+ /* s strcmp(s, "") ==> (*s) */
+ ir_node *mem, *block;
+ dbg_info *dbg;
+ ir_mode *mode;
+
+ v = left;
+replace_by_call:
+ mem = get_Call_mem(call);
+ block = get_nodes_block(call);
+ dbg = get_irn_dbg_info(call);
+ mode = get_type_mode(char_tp);
+
+ /* replace the strcmp by (*x) */
+ irn = new_rd_Load(dbg, block, mem, v, mode, cons_none);
+ mem = new_r_Proj(irn, mode_M, pn_Load_M);
+ exc = new_r_Proj(irn, mode_X, pn_Load_X_except);
+ reg = new_r_Proj(irn, mode_X, pn_Load_X_regular);
+ irn = new_r_Proj(irn, mode, pn_Load_res);
+
+ /* conv to the result mode */
+ mode = get_type_mode(res_tp);
+ irn = new_rd_Conv(dbg, block, irn, mode);
+
+ if (v == right) {
+ /* negate in the ("", s) case */
+ irn = new_rd_Minus(dbg, block, irn, mode);
+ }
+ }
+ }
+
+ if (irn != NULL) {
+ ir_node *mem = get_Call_mem(call);
+ DBG_OPT_ALGSIM0(call, irn, FS_OPT_RTS_STRCMP);
+ replace_call(irn, call, mem, reg, exc);
+ return 1;
+ }
+