<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Multiplying vector type by a floating point constant results in an invalid result"
   href="http://llvm.org/bugs/show_bug.cgi?id=16063">16063</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Multiplying vector type by a floating point constant results in an invalid result
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>LLVM Codegen
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>georgellvmb@oss3d.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Please check the code below. A float vector is multiplied by a double constant.
When the vector size is changed to 4, the code even fails to compile. However
for size 2 it compiles and gives the following wrong results.

>From my analysis of the code, a bitcast instruction is used in LLVM code
generator, which (I presume) simply reinterprets double constant instead of
converting it.

===== EXPECTED OUTPUT:
ORIGINAL: 1.00,1.00
MULTIPLIED: 0.50,0.50

===== ACTUAL OUTPUT:
ORIGINAL: 1.00,1.00
MULTIPLIED: 0.00,1.75

===== CODE:

#include <stdio.h>
#include <math.h>

typedef float tfloat __attribute__((ext_vector_type(2)))  
__attribute__((aligned(8))) ;

int main()
{
    tfloat orig=1.0;


    printf("ORIGINAL: %.2lf,%.2lf\n",(double)orig[0],(double)orig[1]);

    orig = orig*0.5;

    printf("MULTIPLIED: %.2lf,%.2lf\n",(double)orig[0],(double)orig[1]);

    return 0;
}</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>