<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 --- - initialization of global var with a (sqrt) function optimized away"
   href="http://llvm.org/bugs/show_bug.cgi?id=21048">21048</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>initialization of global var with a (sqrt) function optimized away
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>Linux
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>will_schmidt@vnet.ibm.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>Created <span class=""><a href="attachment.cgi?id=13078" name="attach_13078" title="test source">attachment 13078</a> <a href="attachment.cgi?id=13078&action=edit" title="test source">[details]</a></span>
test source

The initialization of a double to NaN (by way of sqrt(-2.01)) is failing, due
to the sqrt call being optimized out.   

Per debug, this appears to be occurring during the "Early CSE" pass. 

opt -O1 -S -o optimized.ll  llvm_debug_variable_init.ll 

The llvm_debug_variable_init.ll file contains a snippet including:

define void @__cxx_global_var_init() section ".text.startup" {
entry:
  %0 = call double @llvm.sqrt.f64(double -2.010000e+00), !dbg !1818
  store double %0, double* getelementptr inbounds (%"NumberUnion"* @fruity ,
i32 0, i32 0), align 8, !dbg !1818
  ret void, !dbg !1818
}

The optimized.ll output contains:
define void @__cxx_global_var_init() #0 section ".text.startup" {
entry:
  store double 0.000000e+00, double* getelementptr inbounds (%NumberUnion*
@fruity, i64 0, i32 0), align 8
  ret void
}

... with no sign of the sqrt call.


output from 
"opt llvm_debug_variable_init.ll  -O1 -S --print-after-all  --print-before-all 
<span class="quote">> optimized_debug.ll 2>&1 " will also be attached momentarily.</span ></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>