]> gcc.gnu.org Git - gcc.git/commitdiff
Fix multiple_of_p behavior with NOP_EXPR
authorRichard Biener <rguenther@suse.de>
Mon, 24 Jan 2022 13:59:00 +0000 (14:59 +0100)
committerRichard Biener <rguenther@suse.de>
Mon, 31 Jan 2022 08:38:10 +0000 (09:38 +0100)
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.

gcc/fold-const.cc

index fd9c6352d4f4f18c7bf761e8386c9039343f8899..b155611578db0c9f1428d0c66b2317b6b4c9b437 100644 (file)
@@ -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);
This page took 0.084847 seconds and 5 git commands to generate.