public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix multiple_of_p behavior with NOP_EXPR
@ 2022-01-24 14:46 Richard Biener
  2022-01-28 18:06 ` Jeff Law
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Biener @ 2022-01-24 14:46 UTC (permalink / raw)
  To: gcc-patches

We were passing down the original type to recursive invocations
of multiple_of_p for say (int)(unsigned * unsigned).

Bootstrap and regtest pending on x86_64-unknown-linux-gnu.

2022-01-24  Richard Biener  <rguenther@suse.de>

	* 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 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index fd9c6352d4f..b155611578d 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);
-- 
2.31.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix multiple_of_p behavior with NOP_EXPR
  2022-01-24 14:46 [PATCH] Fix multiple_of_p behavior with NOP_EXPR Richard Biener
@ 2022-01-28 18:06 ` Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2022-01-28 18:06 UTC (permalink / raw)
  To: Richard Biener, gcc-patches



On 1/24/2022 7:46 AM, Richard Biener via Gcc-patches wrote:
> We were passing down the original type to recursive invocations
> of multiple_of_p for say (int)(unsigned * unsigned).
>
> Bootstrap and regtest pending on x86_64-unknown-linux-gnu.
>
> 2022-01-24  Richard Biener  <rguenther@suse.de>
>
> 	* 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.
OK by me.  Your call on gcc-12 vs gcc-13 timing.
jeff


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-28 18:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-24 14:46 [PATCH] Fix multiple_of_p behavior with NOP_EXPR Richard Biener
2022-01-28 18:06 ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).