+bool ir_zero_when_converted(const ir_node *node, ir_mode *dest_mode)
+{
+ ir_mode *mode = get_irn_mode(node);
+ if (get_mode_arithmetic(mode) != irma_twos_complement
+ || get_mode_arithmetic(dest_mode) != irma_twos_complement)
+ return false;
+
+ if (is_Shl(node)) {
+ ir_node *count = get_Shl_right(node);
+ if (is_Const(count)) {
+ ir_tarval *tv = get_Const_tarval(count);
+ if (tarval_is_long(tv)) {
+ long shiftval = get_tarval_long(tv);
+ long destbits = get_mode_size_bits(dest_mode);
+ if (shiftval >= destbits
+ && shiftval < (long)get_mode_modulo_shift(mode))
+ return true;
+ }
+ }
+ }
+ if (is_And(node)) {
+ ir_node *right = get_And_right(node);
+ if (is_Const(right)) {
+ ir_tarval *tv = get_Const_tarval(right);
+ ir_tarval *conved = tarval_convert_to(tv, dest_mode);
+ return tarval_is_null(conved);
+ }
+ }
+ return false;
+}
+