title: Why don't LLVM passes optimize floating point instructions?
body: <p>See above. I wrote to sample functions:</p>
  
  <p><code>source.ll:</code></p>
  
  <pre><code>define i32 @bleh(i32 %x) {
  entry:
    %addtmp = add i32 %x, %x
    %addtmp1 = add i32 %addtmp, %x
    %addtmp2 = add i32 %addtmp1, %x
    %addtmp3 = add i32 %addtmp2, %x
    %addtmp4 = add i32 %addtmp3, 1
    %addtmp5 = add i32 %addtmp4, 2
    %addtmp6 = add i32 %addtmp5, 3
    %multmp = mul i32 %x, 3
    %addtmp7 = add i32 %addtmp6, %multmp
    ret i32 %addtmp7
  }
  </code></pre>
  
  <p><code>source-fp.ll:</code></p>
  
  <pre><code>define double @bleh(double %x) {
  entry:
    %addtmp = fadd double %x, %x
    %addtmp1 = fadd double %addtmp, %x
    %addtmp2 = fadd double %addtmp1, %x
    %addtmp3 = fadd double %addtmp2, %x
    %addtmp4 = fadd double %addtmp3, 1.000000e+00
    %addtmp5 = fadd double %addtmp4, 2.000000e+00
    %addtmp6 = fadd double %addtmp5, 3.000000e+00
    %multmp = fmul double %x, 3.000000e+00
    %addtmp7 = fadd double %addtmp6, %multmp
    ret double %addtmp7
  }
  </code></pre>
  
  <p>Why is it that when I optimize both functions using</p>
  
  <p><code>opt -O3 source[-fp].ll -o opt.source[-fp].ll -S</code></p>
  
  <p>that the <code>i32</code> one gets optimized but the <code>double</code> one doesn't? I expected the <code>fadd</code> to get combined to a single <code>fmul</code>. Instead it looks exactly the same.</p>
  
  <p>Is it due to the flags being set differently? I am aware of certain optimizations that are possible for <code>i32</code> that are not doable for <code>double</code>. But the absence of simple constant folding is beyond my understanding.</p>
  
  <p>I am using LLVM 3.1.</p>