aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-chrec.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2018-01-24 09:37:41 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2018-01-24 09:37:41 +0000
commit6acfd18c395cca3d0c5acf9d62a3c1556ea58d90 (patch)
treeb490edd97925d19af2b4a4544a79365599ffc269 /gcc/tree-chrec.c
parentda37a70f55338ef295bb1f7a39f9ef3e407835dd (diff)
downloadgcc-6acfd18c395cca3d0c5acf9d62a3c1556ea58d90.zip
gcc-6acfd18c395cca3d0c5acf9d62a3c1556ea58d90.tar.gz
gcc-6acfd18c395cca3d0c5acf9d62a3c1556ea58d90.tar.bz2
re PR tree-optimization/83176 ([graphite] ICE in set_codegen_error, at graphite-isl-ast-to-gimple.c:206)
2018-01-24 Richard Biener <rguenther@suse.de> PR tree-optimization/83176 * tree-chrec.c (chrec_fold_plus_1): Handle (signed T){(T) .. } operands. * gcc.dg/graphite/pr83176.c: New testcase. From-SVN: r257013
Diffstat (limited to 'gcc/tree-chrec.c')
-rw-r--r--gcc/tree-chrec.c38
1 files changed, 34 insertions, 4 deletions
diff --git a/gcc/tree-chrec.c b/gcc/tree-chrec.c
index 924df04..896ff35 100644
--- a/gcc/tree-chrec.c
+++ b/gcc/tree-chrec.c
@@ -295,8 +295,23 @@ chrec_fold_plus_1 (enum tree_code code, tree type,
return chrec_fold_plus_poly_poly (code, type, op0, op1);
CASE_CONVERT:
- if (tree_contains_chrecs (op1, NULL))
- return chrec_dont_know;
+ {
+ /* We can strip sign-conversions to signed by performing the
+ operation in unsigned. */
+ tree optype = TREE_TYPE (TREE_OPERAND (op1, 0));
+ if (INTEGRAL_TYPE_P (type)
+ && INTEGRAL_TYPE_P (optype)
+ && tree_nop_conversion_p (type, optype)
+ && TYPE_UNSIGNED (optype))
+ return chrec_convert (type,
+ chrec_fold_plus_1 (code, optype,
+ chrec_convert (optype,
+ op0, NULL),
+ TREE_OPERAND (op1, 0)),
+ NULL);
+ if (tree_contains_chrecs (op1, NULL))
+ return chrec_dont_know;
+ }
/* FALLTHRU */
default:
@@ -313,8 +328,23 @@ chrec_fold_plus_1 (enum tree_code code, tree type,
}
CASE_CONVERT:
- if (tree_contains_chrecs (op0, NULL))
- return chrec_dont_know;
+ {
+ /* We can strip sign-conversions to signed by performing the
+ operation in unsigned. */
+ tree optype = TREE_TYPE (TREE_OPERAND (op0, 0));
+ if (INTEGRAL_TYPE_P (type)
+ && INTEGRAL_TYPE_P (optype)
+ && tree_nop_conversion_p (type, optype)
+ && TYPE_UNSIGNED (optype))
+ return chrec_convert (type,
+ chrec_fold_plus_1 (code, optype,
+ TREE_OPERAND (op0, 0),
+ chrec_convert (optype,
+ op1, NULL)),
+ NULL);
+ if (tree_contains_chrecs (op0, NULL))
+ return chrec_dont_know;
+ }
/* FALLTHRU */
default: