We were passing down the original type to recursive invocations
of multiple_of_p for say (int)(unsigned * unsigned).
2022-01-24 Richard Biener <rguenther@suse.de>
PR tree-optimization/100499
* fold-const.cc (multiple_of_p): Pass the correct type of
the expression to the recursive invocation of multiple_of_p
for conversions and use CASE_CONVERT.
}
return 0;
- case NOP_EXPR:
+ CASE_CONVERT:
/* Can't handle conversions from non-integral or wider integral type. */
if ((TREE_CODE (TREE_TYPE (TREE_OPERAND (top, 0))) != INTEGER_TYPE)
|| (TYPE_PRECISION (type)
< TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (top, 0)))))
return 0;
-
- /* fall through */
+ return multiple_of_p (TREE_TYPE (TREE_OPERAND (top, 0)),
+ TREE_OPERAND (top, 0), bottom);
case SAVE_EXPR:
return multiple_of_p (type, TREE_OPERAND (top, 0), bottom);