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

    <tr>
        <th>Summary</th>
        <td>
            clang frontend losses precision while operation on floats and doubles.
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          long5hot
      </td>
    </tr>
</table>

<pre>
    clang frontend loses precision when doing operation on floats and doubles
the main cause of this is when frontend tries to simplify FMA operation.

PR : https://godbolt.org/z/7Y8cex7Yh

Exact pass : https://godbolt.org/z/chWEdzE6G

`#include<stdlib.h>
#include<stdio.h>

double * createHeapArray() {
    double *HeapArray = (double *)malloc(sizeof(double)*10);
    double count = 1.0;
    for(int IDX =0 ; IDX <10 ; IDX++) {
      HeapArray[IDX] = 0.1 * count + 1.0;
 count++;
    }   
  return HeapArray;
}

int main() {
 
    double array[10] ; //= {1.1, 1.2, 1.3, 1.4, 1.5,1.6, 1.7, 1.8, 1.9, 2.0};
    double count = 1.0;
    for(int IDX =0 ; IDX <10 ; IDX++) {
        array[IDX] = 0.1 * count + 1.0;
    count = count + 1.0;
 } 
    double *heapArray = createHeapArray();
    for(int i=0; i<10; i++) {
      if(array[i] != heapArray[i]) {
        printf("Test Fail\n");
        return 0;
      }   
    }   
 printf("Test Pass\n");    
    return 1;
}`
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VcuO4zYQ_JrWpbEC2bReBx38GCU5BFgEAZI90hJlMaBJQ6SyO_P1ASWvX-NB9rSGoTbZza6qdkGU3uuDVaqGbAPZLpFTGNxYG2cP2eBCsnfda90aaQ_Yj84GZTs0ziuPp1G12mtn8eugLHZO2wO6kxpliJvOYm-cDB6l7bBz094oD2wHbB0GhUepLbZy8gpdj2HQHrVfOl1wwqiVx-DQ6-PJ6P4Vm9_XV4h06bY8P_-BINY4hHDyINZADVBzcN3emZC68QDUvAE1xZeyVd-KL8Pt2Zdvsg14kt7_UI92-Oule3vJf7ntATkDEtq2ZuoUiK0PndH7dADxci54yGp3m5yfy5AQaI3tqGRQvyp5Wo-jfAUqgSqEYrNUIiJeqy9lCGKHQOU1BVQdpTGuBSq9flOuv6SBKqA1ZzGK931bN9kwN-Qpuyvo3QhUahvwt93fsYIhiM15seWXFdBm_j7wRrzKyjaxLtvNOCzli_YFmTb3yPP2uectHSh28XlejypMo72B-F4Kxe521pF-9OC7yb4bhDwz5WwhusHFGPOsiw1POdAWeUpLEEtYLSED2vI0XxbFEsolVDFQyiKxnzt_vGj68ekj3jD6oCb-E8_8Odz586m1PxCoo7ooR8_Kll8fydLR29-V6VkX8Yg43Pgt7j8dyWnUNvQzG_pT-YCN1AayrQWiR4LxczYae0jcu_Fh_Q7js_T-DgPvDp8x-J2Jc5Z0tegqUclE1TwvcxJMZCIZatm21PY55b1YZUUhqaC9rDgxofgqpyrRNTESLGclF7zilBJVmWpZmXdSsKxnsGLqKLVJjfn3GN95ifZ-UnUueMUSI_fK-PmqILLqK87JSD7bJWMdz3zaTwcPK2a0D_7aJehg1JN75PEi0Ub93x2SJtNo6oeXtA7DtE9bdwRqIug5fDqN7h_VBqBmpuqBmlnKfwEAAP__tkPu1g">