<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/75603>75603</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            unexpected output results in fusion using -O3 and -Ofast
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Elowen-jjw
      </td>
    </tr>
</table>

<pre>
    For the following two c files, I performed the equivalent transformation of loop from **file1.c** to **file2.c**. I ran these two files respectively using different optimization levels including **-O0**, **-O1**, **-O2**, **-O3**, **-Os**, **-Ofast**. The exact output results(i.e. checksum values) are:
```
              -O0 -O1             -O2             -O3             -Os             -Ofast 
file1.c       A7B46528        A7B46528        A7B46528        EF8E7A05 A7B46528        EF8E7A05     
file2.c       A7B46528        A7B46528 A7B46528        A7B46528        A7B46528        A7B46528    
```
 
Please help me to explain why these two files produced different output results when using the same optimization level(i.e. -O3 and -Ofast), thank you.

command line:
```
clang <filename.c> <optimization level> -lm -I $CSMITH_HOME/include && ./a.out
```
version: clang+llvm 14.0.0
os: ubuntu 22.04

**file1.c**
```

#include "csmith.h"

static int32_t g_a78[4];
static uint64_t g_b78[4];

struct S0 {
  const volatile uint32_t f0;
  uint64_t f1;
  int64_t f2;
};

union U1 {
  int16_t f0;
  uint16_t f1;
  uint16_t f2;
  const struct S0 f3;
};

static volatile int32_t g_3 = 0x48708EF6L;
static volatile int32_t g_8[3] = {0x597A61EEL, 0x597A61EEL, 0x597A61EEL};
static int32_t g_10 = 1L;
static int32_t *g_29 = (void *)0;
static int32_t **g_28 = &g_29;
static volatile int32_t g_32[1][3] = {{0x4C46983CL, 0x4C46983CL, 0x4C46983CL}};
static int32_t g_33[2][3][1] = {{{(-7L)}, {(-7L)}, {(-7L)}}, {{(-7L)}, {(-7L)}, {(-7L)}}};
static volatile struct S0 g_64 = {0xC15C487EL, 0x8E1234CD2740D6A5LL, 0x8E70C497A14F8299LL};
static const volatile struct S0 g_84 = {0x1624B3AEL, 0x4CD7CE17D650891FLL, 0x5DEE7F6E9516CEA6LL};
static int32_t g_101 = 1L;
static int32_t *volatile g_100 = &g_101;
static int32_t g_169[2][2][1] = {{{1L}, {0x0E6156E5L}}, {{1L}, {0x0E6156E5L}}};
static uint16_t g_215 = 0UL;
static int64_t g_234 = 0x4AA72A53C6A8003FLL;
static union U1 g_272[1] = {{0xB220L}};
static union U1 g_299 = {0xE9D8L};
static volatile union U1 g_320 = {1L};
static union U1 *g_340 = &g_272[0];
static union U1 **volatile g_339 = &g_340;
static struct S0 g_350 = {2UL, 18446744073709551615UL, 0x484C2F172B251D2FLL};
static int8_t g_503 = 0xFEL;

static const void func_1(void);

static const void func_1(void) {
  int32_t l_385 = 0x5A33D8C8L;
  int32_t l_398 = 0L;
  // fusion
  for (int t = 1, ii_2 = 0; (t >= 0); t -= 1, ii_2++) {
    uint8_t l_384 = 0x67L;
    uint64_t *l_406 = (void *)0;
 for (int k = 0; (k <= 1); k += 1) {
      int i;
      for (i = 0; i < 2; i++) {
        g_a78[ii_2] = g_3 * g_33[0][2][0] - (**g_339).f0;
 }
      (*g_100) = ((0x556123D4L <= ((g_299.f1) = (safe_lshift_func_uint16_t_u_u((!(safe_lshift_func_int8_t_s_s(((((g_234) &= (-1L)), g_234) || g_350.f1), g_32[0][1]))), 7L)))) >= 0xA0B92A34L);
 }
    g_8[(g_10 + 1)] = ((0x40D6200CL | ((l_385 &= (safe_add_func_int8_t_s_s((safe_div_func_uint8_t_u_u(1UL, g_320.f0)), l_384))) != g_33[1][1][0])) < g_10);
    if ((safe_mul_func_uint64_t_u_u((l_385 ^ (safe_lshift_func_uint16_t_u_u((g_215 |= ((safe_div_func_uint32_t_u_u(((safe_mul_func_uint64_t_u_u(g_33[0][1][0], 0x4CCD9B15L)) && l_398), l_385)) != g_84.f2)), g_350.f2))), 0x40A8940BA3C26A6CLL))) {
      int16_t l_405[2][3] = {{0xFE45L, 0xFE45L, 0x7242L}, {0xFE45L, 0xFE45L, 0x7242L}};
      l_385 = (safe_mul_func_int32_t_s_s(((safe_add_func_int16_t_s_s((l_405[0][2] = (-2L)), (l_406 != (void *)0))), (*g_100)), g_169[1][0][0]));
    } else {
 (*g_28) = &l_398;
    }
  }
  int jj_2;
  for (jj_2 = 0; jj_2 < 4; jj_2++) {
    g_b78[jj_2] = g_503 * g_a78[jj_2] - g_64.f1;
  }
 g_169[0][0][0] ^= (*g_100);
}

int main(void) {
  int i, j, k;
  int print_hash_value = 0;
  platform_main_begin();
 crc32_gentab();
  func_1();
  transparent_crc(g_3, "g_3", print_hash_value);
  for (i = 0; i < 3; i++) {
 transparent_crc(g_8[i], "g_8[i]", print_hash_value);
  }
 transparent_crc(g_10, "g_10", print_hash_value);
  for (i = 0; i < 1; i++) {
    for (j = 0; j < 3; j++) {
      transparent_crc(g_32[i][j], "g_32[i][j]", print_hash_value);
    }
  }
  for (i = 0; i < 2; i++) {
    for (j = 0; j < 3; j++) {
      for (k = 0; k < 1; k++) {
        transparent_crc(g_33[i][j][k], "g_33[i][j][k]", print_hash_value);
      }
    }
  }
  transparent_crc(g_64.f0, "g_64.f0", print_hash_value);
  transparent_crc(g_64.f1, "g_64.f1", print_hash_value);
  transparent_crc(g_64.f2, "g_64.f2", print_hash_value);
  transparent_crc(g_84.f0, "g_84.f0", print_hash_value);
  transparent_crc(g_84.f1, "g_84.f1", print_hash_value);
  transparent_crc(g_84.f2, "g_84.f2", print_hash_value);
  transparent_crc(g_101, "g_101", print_hash_value);
  for (i = 0; i < 2; i++) {
    for (j = 0; j < 2; j++) {
      for (k = 0; k < 1; k++) {
 transparent_crc(g_169[i][j][k], "g_169[i][j][k]", print_hash_value);
 }
    }
  }
  transparent_crc(g_215, "g_215", print_hash_value);
  transparent_crc(g_234, "g_234", print_hash_value);
  for (i = 0; i < 1; i++) {
 transparent_crc(g_272[i].f0, "g_272[i].f0", print_hash_value);
  }
 transparent_crc(g_320.f0, "g_320.f0", print_hash_value);
 transparent_crc(g_350.f0, "g_350.f0", print_hash_value);
 transparent_crc(g_350.f1, "g_350.f1", print_hash_value);
 transparent_crc(g_350.f2, "g_350.f2", print_hash_value);
 transparent_crc(g_503, "g_503", print_hash_value);
  for (i = 0; i < 4; i++) {
    transparent_crc(g_a78[i], "g_a78[i]", print_hash_value);
 }
  for (i = 0; i < 4; i++) {
    transparent_crc(g_b78[i], "g_b78[i]", print_hash_value);
  }
  platform_main_end(crc32_context ^ 0xFFFFFFFFUL, print_hash_value);
  return 0;
}

```

**file2.c**
```

#include "csmith.h"

static int32_t g_a78[4];
static uint64_t g_b78[4];

struct S0 {
  const volatile uint32_t f0;
  uint64_t f1;
  int64_t f2;
};

union U1 {
  int16_t f0;
  uint16_t f1;
  uint16_t f2;
  const struct S0 f3;
};

static volatile int32_t g_3 = 0x48708EF6L;
static volatile int32_t g_8[3] = {0x597A61EEL, 0x597A61EEL, 0x597A61EEL};
static int32_t g_10 = 1L;
static int32_t *g_29 = (void *)0;
static int32_t **g_28 = &g_29;
static volatile int32_t g_32[1][3] = {{0x4C46983CL, 0x4C46983CL, 0x4C46983CL}};
static int32_t g_33[2][3][1] = {{{(-7L)}, {(-7L)}, {(-7L)}}, {{(-7L)}, {(-7L)}, {(-7L)}}};
static volatile struct S0 g_64 = {0xC15C487EL, 0x8E1234CD2740D6A5LL, 0x8E70C497A14F8299LL};
static const volatile struct S0 g_84 = {0x1624B3AEL, 0x4CD7CE17D650891FLL, 0x5DEE7F6E9516CEA6LL};
static int32_t g_101 = 1L;
static int32_t *volatile g_100 = &g_101;
static int32_t g_169[2][2][1] = {{{1L}, {0x0E6156E5L}}, {{1L}, {0x0E6156E5L}}};
static uint16_t g_215 = 0UL;
static int64_t g_234 = 0x4AA72A53C6A8003FLL;
static union U1 g_272[1] = {{0xB220L}};
static union U1 g_299 = {0xE9D8L};
static volatile union U1 g_320 = {1L};
static union U1 *g_340 = &g_272[0];
static union U1 **volatile g_339 = &g_340;
static struct S0 g_350 = {2UL, 18446744073709551615UL, 0x484C2F172B251D2FLL};
static int8_t g_503 = 0xFEL;

static const void func_1(void);

static const void func_1(void) {
  int32_t l_385 = 0x5A33D8C8L;
  int32_t l_398 = 0L;
  // fusion
  for (int t = 1, ii_2 = 0, jj_2 = 0, ij_2 = 0; ij_2 <= 4; ij_2++) {
    if (ij_2 <= 2 && (t >= 0)) {
      uint8_t l_384 = 0x67L;
      uint64_t *l_406 = (void *)0;
      for (int k = 0; (k <= 1); k += 1) {
        int i;
        for (i = 0; i < 2; i++) {
 g_a78[ii_2] = g_3 * g_33[0][2][0] - (**g_339).f0;
        }
 (*g_100) = ((0x556123D4L <= ((g_299.f1) = (safe_lshift_func_uint16_t_u_u((!(safe_lshift_func_int8_t_s_s(((((g_234) &= (-1L)), g_234) || g_350.f1), g_32[0][1]))), 7L)))) >= 0xA0B92A34L);
 }
      g_8[(g_10 + 1)] = ((0x40D6200CL | ((l_385 &= (safe_add_func_int8_t_s_s((safe_div_func_uint8_t_u_u(1UL, g_320.f0)), l_384))) != g_33[1][1][0])) < g_10);
      if ((safe_mul_func_uint64_t_u_u((l_385 ^ (safe_lshift_func_uint16_t_u_u((g_215 |= ((safe_div_func_uint32_t_u_u(((safe_mul_func_uint64_t_u_u(g_33[0][1][0], 0x4CCD9B15L)) && l_398), l_385)) != g_84.f2)), g_350.f2))), 0x40A8940BA3C26A6CLL))) {
        int16_t l_405[2][3] = {{0xFE45L, 0xFE45L, 0x7242L}, {0xFE45L, 0xFE45L, 0x7242L}};
        l_385 = (safe_mul_func_int32_t_s_s(((safe_add_func_int16_t_s_s((l_405[0][2] = (-2L)), (l_406 != (void *)0))), (*g_100)), g_169[1][0][0]));
      } else {
 (*g_28) = &l_398;
      }
      t -= 1;
      ii_2++;
 }
    if (ij_2 <= 4 && jj_2 < 4) {
      g_b78[jj_2] = g_503 * g_a78[jj_2] - g_64.f1;
      jj_2++;
    }
  }
  g_169[0][0][0] ^= (*g_100);
}

int main(void) {
  int i, j, k;
  int print_hash_value = 0;
  platform_main_begin();
  crc32_gentab();
 func_1();
  transparent_crc(g_3, "g_3", print_hash_value);
  for (i = 0; i < 3; i++) {
    transparent_crc(g_8[i], "g_8[i]", print_hash_value);
  }
  transparent_crc(g_10, "g_10", print_hash_value);
  for (i = 0; i < 1; i++) {
    for (j = 0; j < 3; j++) {
      transparent_crc(g_32[i][j], "g_32[i][j]", print_hash_value);
    }
  }
  for (i = 0; i < 2; i++) {
    for (j = 0; j < 3; j++) {
      for (k = 0; k < 1; k++) {
 transparent_crc(g_33[i][j][k], "g_33[i][j][k]", print_hash_value);
 }
    }
  }
  transparent_crc(g_64.f0, "g_64.f0", print_hash_value);
  transparent_crc(g_64.f1, "g_64.f1", print_hash_value);
  transparent_crc(g_64.f2, "g_64.f2", print_hash_value);
  transparent_crc(g_84.f0, "g_84.f0", print_hash_value);
  transparent_crc(g_84.f1, "g_84.f1", print_hash_value);
  transparent_crc(g_84.f2, "g_84.f2", print_hash_value);
  transparent_crc(g_101, "g_101", print_hash_value);
  for (i = 0; i < 2; i++) {
    for (j = 0; j < 2; j++) {
      for (k = 0; k < 1; k++) {
 transparent_crc(g_169[i][j][k], "g_169[i][j][k]", print_hash_value);
 }
    }
  }
  transparent_crc(g_215, "g_215", print_hash_value);
  transparent_crc(g_234, "g_234", print_hash_value);
  for (i = 0; i < 1; i++) {
 transparent_crc(g_272[i].f0, "g_272[i].f0", print_hash_value);
  }
 transparent_crc(g_320.f0, "g_320.f0", print_hash_value);
 transparent_crc(g_350.f0, "g_350.f0", print_hash_value);
 transparent_crc(g_350.f1, "g_350.f1", print_hash_value);
 transparent_crc(g_350.f2, "g_350.f2", print_hash_value);
 transparent_crc(g_503, "g_503", print_hash_value);
  for (i = 0; i < 4; i++) {
    transparent_crc(g_a78[i], "g_a78[i]", print_hash_value);
 }
  for (i = 0; i < 4; i++) {
    transparent_crc(g_b78[i], "g_b78[i]", print_hash_value);
  }
  platform_main_end(crc32_context ^ 0xFFFFFFFFUL, print_hash_value);
  return 0;
}

```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsG1lv4rr617gvFsj-nPWhDyEEnZE4miudM89RCAbShoSbpWXur7-yszkLlCkzdzkHVLXx9u2b85Ugz6N9wvkz0hdIXz4FZXFIs2cvTt95Mnt5eX_apNvvz6s0w8WB410ax-l7lOxx8Z7iEO-imOcIXPwFn3i2S7Mj38qN_J9l9BbEPClwkQVJLpaCIkoTnO5wnKYnvMvSI0bgIHAEFDoPqwEuUmUamuk5_oKzIBHAcy6xS9w44_mJh0X0xuPvuMwFadtot-OZQJ2eiugY_atCHPM3Huc4SsK43Ip9FeDZV1I9CDaaKTqegvEUG0_l46ldkBcND38K0ZyDsMBpWZzKQpBfxkWOwIrmfI7DAw9f8_KI34K4FJK1cZBxxBxElog4yCD1jxzi3mf2leDZVzqYg8GYDcb5YCyoxRX4Wi31kmMuNEMHC9849laWZzpEv7wgPh0m-BjTj5KgjqcFWP35R8yDnOMDj0_4yIUB8vMpDqIEvx--jyzulKXbMuRb1c56ysTvB57Utih8IQ-OfMIUG50LnQTJFjeWYgvjKQ5B8oq_p-W8Jlz-DtPjUWyNo-SiUYRxIGybuYLaJDjyeYiYJyYmSGAensVHPPuCEWjuH79_-fM3_7evv3sIVpWfcIzAQGDgOYJVME_LYhLpG8_yKE0Qc7DEj2ARx29HTLU5mdd70lwsl5syKUoMMCeaytpEJJjE1OxmHX0Q5seoOMwPCEDdlBdBEYU4SgoGfoH3fmBaSF9oSF8itujtKaOkMDS5aTPe1GzNyrDAfxCMzEXjgGGa5AV-S-OgiGIu4UhkO9Kexh30HVVm20noEJlDpGUilPWNqjijpKDGFI5qlk7OgjJbEd3xs2NXKKgl1LLYiZNhxJaYnDXLJJa3MtZDqU6cEbJlSF_Ko8hckLNum45BPW8tzP7K0BwprYNKiYRHRxQ0WxA4ex_sCitYb2m0reKzTa4cqU5Z9SlDQLiBRQZIX1BhP31WJbeaqxm2xdyavYt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