From: Richard Biener Date: Mon, 24 Jan 2022 13:59:00 +0000 (+0100) Subject: Fix multiple_of_p behavior with NOP_EXPR X-Git-Tag: upstream/12.2.0~1758 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=625f16c798757dcbfdded841f01d7c566d15c55c;p=platform%2Fupstream%2Fgcc.git Fix multiple_of_p behavior with NOP_EXPR We were passing down the original type to recursive invocations of multiple_of_p for say (int)(unsigned * unsigned). 2022-01-24 Richard Biener 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. --- diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc index fd9c635..b155611 100644 --- a/gcc/fold-const.cc +++ b/gcc/fold-const.cc @@ -14149,14 +14149,14 @@ multiple_of_p (tree type, const_tree top, const_tree bottom) } 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);