aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/gimple-ssa-strength-reduction.cc5
-rw-r--r--gcc/testsuite/g++.dg/torture/pr123820-1.C41
2 files changed, 44 insertions, 2 deletions
diff --git a/gcc/gimple-ssa-strength-reduction.cc b/gcc/gimple-ssa-strength-reduction.cc
index f3571e10e90..ced2235498c 100644
--- a/gcc/gimple-ssa-strength-reduction.cc
+++ b/gcc/gimple-ssa-strength-reduction.cc
@@ -2356,10 +2356,11 @@ create_add_on_incoming_edge (slsr_cand_t c, tree basis_name,
}
else {
tree stride;
+ tree wanted_type = POINTER_TYPE_P (basis_type) ? c->stride_type : basis_type;
- if (!types_compatible_p (TREE_TYPE (c->stride), c->stride_type))
+ if (!types_compatible_p (TREE_TYPE (c->stride), wanted_type))
{
- tree cast_stride = make_temp_ssa_name (c->stride_type, NULL,
+ tree cast_stride = make_temp_ssa_name (wanted_type, NULL,
"slsr");
cast_stmt = gimple_build_assign (cast_stride, NOP_EXPR,
c->stride);
diff --git a/gcc/testsuite/g++.dg/torture/pr123820-1.C b/gcc/testsuite/g++.dg/torture/pr123820-1.C
new file mode 100644
index 00000000000..3c9d1f0127a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr123820-1.C
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* PR tree-optimization/123820 */
+
+struct Trit { char value; };
+
+struct Matrix {
+ int width;
+ Trit* data;
+
+ Trit& at(int x, int y) {
+ if (!(x >= y)) __builtin_abort ();
+ return data[y * width];
+ }
+};
+
+
+Trit set_value;
+[[gnu::used]]
+int EmbedPositionDetectionPattern_yStart;
+
+[[gnu::used,gnu::noipa]]
+void EmbedPositionDetectionPattern(Matrix& m) {
+ for (int y = 0; y < 7; ++y)
+ for (int x = 0; x < 7; ++x)
+ m.at(x, EmbedPositionDetectionPattern_yStart + y) = {0};
+
+ for (int i = 1; i < 8; ++i) {
+ if (i < m.width)
+ m.at(i, 7) = {0};
+
+ int y = EmbedPositionDetectionPattern_yStart + i;
+ if (7 < m.width && y)
+ m.at(7, y) = {0};
+ }
+}
+
+int main()
+{
+ return 0;
+}
+