diff options
author | Richard Biener <rguenther@suse.de> | 2022-04-04 10:20:05 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2022-04-04 11:34:25 +0200 |
commit | eaaf77dd85c333b116111bb1ae6c080154a4e411 (patch) | |
tree | 91951066c1414e71f93383f2adc88b286b2ed678 /gcc/fold-const.cc | |
parent | f6b786d749812542dae90db1701a3cfdccfa1e4b (diff) | |
download | gcc-eaaf77dd85c333b116111bb1ae6c080154a4e411.zip gcc-eaaf77dd85c333b116111bb1ae6c080154a4e411.tar.gz gcc-eaaf77dd85c333b116111bb1ae6c080154a4e411.tar.bz2 |
middle-end/105140 - fix bogus recursion in fold_convertible_p
fold_convertible_p expects an operand and a type to convert to
but recurses with two vector component types. Fixed by allowing
types instead of an operand as well.
2022-04-04 Richard Biener <rguenther@suse.de>
PR middle-end/105140
* fold-const.cc (fold_convertible_p): Allow a TYPE_P arg.
* gcc.dg/pr105140.c: New testcase.
Diffstat (limited to 'gcc/fold-const.cc')
-rw-r--r-- | gcc/fold-const.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc index b647e53..fb08fa1 100644 --- a/gcc/fold-const.cc +++ b/gcc/fold-const.cc @@ -2379,12 +2379,13 @@ build_zero_vector (tree type) return build_vector_from_val (type, t); } -/* Returns true, if ARG is convertible to TYPE using a NOP_EXPR. */ +/* Returns true, if ARG, an operand or a type, is convertible to TYPE + using a NOP_EXPR. */ bool fold_convertible_p (const_tree type, const_tree arg) { - tree orig = TREE_TYPE (arg); + const_tree orig = TYPE_P (arg) ? arg : TREE_TYPE (arg); if (type == orig) return true; |