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-NEXT:    [[TMP1:%.*]] = fmul fast float %y, %x
      8 ; CHECK-NEXT:    [[TMP2:%.*]] = fmul fast float %y, %x
      9 ; CHECK-NEXT:    [[TMP3:%.*]] = fsub fast float [[TMP1]], [[TMP2]]
     10 ; CHECK-NEXT:    call void @use(float [[TMP1]])
     11 ; CHECK-NEXT:    call void @use(float [[TMP3]])
     12 ; CHECK-NEXT:    ret void
     13 ;
     14   %1 = fmul fast float %x, %y
     15   %2 = fmul fast float %y, %x
     16   %3 = fsub fast float %1, %2
     17   call void @use(float %1)
     18   call void @use(float %3)
     19   ret void
     20 }
     21 
     22 define float @test2(float %x, float %y) {
     23 ; CHECK-LABEL: @test2(
     24 ; CHECK-NEXT:    [[TMP1:%.*]] = fmul fast float %y, %x
     25 ; CHECK-NEXT:    [[TMP2:%.*]] = fmul fast float %y, %x
     26 ; CHECK-NEXT:    [[TMP3:%.*]] = fsub fast float [[TMP1]], [[TMP2]]
     27 ; CHECK-NEXT:    ret float [[TMP3]]
     28 ;
     29   %1 = fmul fast float %x, %y
     30   %2 = fmul fast float %y, %x
     31   %3 = fsub fast float %1, %2
     32   ret float %3
     33 }
     34 
     35 define float @test3(float %x, float %y) {
     36 ; CHECK-LABEL: @test3(
     37 ; CHECK-NEXT:    [[FACTOR:%.*]] = fmul fast float %y, %x
     38 ; CHECK-NEXT:    [[REASS_MUL:%.*]] = fmul fast float [[FACTOR]], 2.000000e+00
     39 ; CHECK-NEXT:    ret float [[REASS_MUL]]
     40 ;
     41   %1 = fmul fast float %x, %y
     42   %2 = fmul fast float %y, %x
     43   %3 = fadd fast float %1, %2
     44   ret float %3
     45 }
     46 
     47