Home | History | Annotate | Download | only in X86
      1 ; RUN: llc < %s -enable-unsafe-fp-math -mtriple=x86_64-apple-darwin -mcpu=corei7-avx | FileCheck %s 
      2 
      3 
      4 ; rdar://13126763
      5 ; Expression "x + x*x" was mistakenly transformed into "x * 3.0f".
      6 
      7 define float @test1(float %x) {
      8   %t1 = fmul fast float %x, %x
      9   %t2 = fadd fast float %t1, %x
     10   ret float %t2
     11 ; CHECK: test1
     12 ; CHECK: vaddss
     13 }
     14 
     15 ; (x + x) + x => x * 3.0
     16 define float @test2(float %x) {
     17   %t1 = fadd fast float %x, %x
     18   %t2 = fadd fast float %t1, %x
     19   ret float %t2
     20 ; CHECK: .long  1077936128
     21 ; CHECK: test2
     22 ; CHECK: vmulss LCPI1_0(%rip), %xmm0, %xmm0
     23 }
     24 
     25 ; x + (x + x) => x * 3.0
     26 define float @test3(float %x) {
     27   %t1 = fadd fast float %x, %x
     28   %t2 = fadd fast float %t1, %x
     29   ret float %t2
     30 ; CHECK: .long  1077936128
     31 ; CHECK: test3
     32 ; CHECK: vmulss LCPI2_0(%rip), %xmm0, %xmm0
     33 }
     34 
     35 ; (y + x) + x != x * 3.0
     36 define float @test4(float %x, float %y) {
     37   %t1 = fadd fast float %x, %y
     38   %t2 = fadd fast float %t1, %x
     39   ret float %t2
     40 ; CHECK: test4
     41 ; CHECK: vaddss
     42 }
     43 
     44 ; rdar://13445387
     45 ; "x + x + x => 3.0 * x" should be disabled after legalization because 
     46 ; Instruction-Selection doesn't know how to handle "3.0"
     47 ; 
     48 define float @test5() {
     49   %mul.i.i151 = fmul <4 x float> zeroinitializer, zeroinitializer
     50   %vecext.i8.i152 = extractelement <4 x float> %mul.i.i151, i32 1
     51   %vecext1.i9.i153 = extractelement <4 x float> %mul.i.i151, i32 0
     52   %add.i10.i154 = fadd float %vecext1.i9.i153, %vecext.i8.i152
     53   %vecext.i7.i155 = extractelement <4 x float> %mul.i.i151, i32 2
     54   %add.i.i156 = fadd float %vecext.i7.i155, %add.i10.i154
     55   ret float %add.i.i156
     56 }
     57