Home | History | Annotate | Download | only in Reassociate
      1 ; RUN: opt -reassociate -S < %s | FileCheck %s
      2 
      3 declare void @use(float)
      4 
      5 define void @test1(float %x, float %y) {
      6 ; CHECK-LABEL: test1
      7 ; CHECK: fmul fast float %y, %x
      8 ; CHECK: fmul fast float %y, %x
      9 ; CHECK: fsub fast float %1, %2
     10 ; CHECK: call void @use(float %{{.*}})
     11 ; CHECK: call void @use(float %{{.*}})
     12 
     13   %1 = fmul fast float %x, %y
     14   %2 = fmul fast float %y, %x
     15   %3 = fsub fast float %1, %2
     16   call void @use(float %1)
     17   call void @use(float %3)
     18   ret void
     19 }
     20 
     21 define float @test2(float %x, float %y) {
     22 ; CHECK-LABEL: test2
     23 ; CHECK-NEXT: fmul fast float %y, %x
     24 ; CHECK-NEXT: fmul fast float %y, %x
     25 ; CHECK-NEXT: fsub fast float %1, %2
     26 ; CHECK-NEXT: ret float %3
     27 
     28   %1 = fmul fast float %x, %y
     29   %2 = fmul fast float %y, %x
     30   %3 = fsub fast float %1, %2
     31   ret float %3
     32 }
     33 
     34 define float @test3(float %x, float %y) {
     35 ; CHECK-LABEL: test3
     36 ; CHECK-NEXT: %factor = fmul fast float %x, 2.000000e+00
     37 ; CHECK-NEXT: %tmp1 = fmul fast float %factor, %y
     38 ; CHECK-NEXT: ret float %tmp1
     39 
     40   %1 = fmul fast float %x, %y
     41   %2 = fmul fast float %y, %x
     42   %3 = fadd fast float %1, %2
     43   ret float %3
     44 }
     45