/*
- * Copyright (C) 1995-2010 University of Karlsruhe. All right reserved.
- *
* This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
+ * Copyright (C) 2012 University of Karlsruhe.
*/
/**
break;
}
+ case iro_Minus: {
+ ir_mode *mode = get_irn_mode(irn);
+
+ /* If all bits except the highest bit are zero the Minus is superfluous. */
+ if (get_mode_arithmetic(mode) == irma_twos_complement) {
+ ir_node *const op = get_Minus_op(irn);
+ bitinfo const *const b = get_bitinfo(op);
+ ir_tarval *const min = get_mode_min(mode);
+
+ if (b->z == min) {
+ DB((dbg, LEVEL_2, "%+F(%+F) is superfluous\n", irn, op));
+ exchange(irn, op);
+ env->modified = 1;
+ }
+ }
+ break;
+ }
+
case iro_Or: {
ir_node* const l = get_Or_left(irn);
ir_node* const r = get_Or_right(irn);