https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105198

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
So it's predictive commoning that triggers the miscompile, it works with
-fno-predictive-commoning.  predcom does

--- a-t.c.167t.dce6     2022-04-08 10:59:28.824746581 +0200
+++ a-t.c.168t.pcom     2022-04-08 10:59:28.824746581 +0200
@@ -4,6 +4,7 @@
 __attribute__((noipa, noinline, noclone, no_icf))
 void next_set (int * x, int n, int k)
 {
+  int D__lsm0.19;
   vector(4) int * vectp.18;
   vector(4) int * vectp.17;
   vector(4) int vect_tmp_55.16;
@@ -117,6 +118,7 @@
   [t.c:43:8] _13 = [t.c:43:8] *_12;
   [t.c:43:11] _14 = _13 + 1;
   [t.c:43:11] [t.c:43:8] *_12 = _14;
+  D__lsm0.19_72 = _14;
   [t.c:40:17] if (j_49 > 0)
     goto <bb 19>; [94.50%]
   else
@@ -132,11 +134,12 @@

   <bb 6> [local count: 1014686026]:
   # j_73 = PHI <[t.c:42:8] j_49(19), [t.c:34:7] j_46(15)>
-  # tmp_75 = PHI <[t.c:43:11] _14(19), [t.c:35:9] _8(15)>
+  # D__lsm0.19_77 = PHI <D__lsm0.19_72(19), _8(15)>
+  tmp_75 = D__lsm0.19_77;
   [t.c:40:21] _16 = (long unsigned int) j_73;
   [t.c:40:21] _17 = _16 * 4;
   [t.c:40:21] _18 = x_47(D) + _17;
-  [t.c:40:21] _19 = [t.c:40:21] *_18;
+  [t.c:40:21] _19 = D__lsm0.19_77;
   [t.c:40:39] _21 = j_46 - j_73;
   [t.c:40:30] _22 = n_41(D) - _21;
   [t.c:40:17] if (_19 >= _22)

which at first doesn't look wrong, but when disabling PRE (which without
vectorization would do the same transform) the issue also shows up w/o
vectorization

 -O2 -fno-tree-vectorize -fno-tree-pre -fpredictive-commoning

Reply via email to