Home | History | Annotate | Download | only in InstCombine
      1 ; RUN: opt < %s -instcombine -S -o - | FileCheck %s
      2 
      3 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
      4 
      5 ; CHECK-LABEL: define float @func1(
      6 define float @func1(float %a, float %b, float %c, i1 %cond) {
      7 entry:
      8   br i1 %cond, label %cond.true, label %cond.false
      9 
     10 cond.true:
     11   %sub0 = fsub fast float %a, %b
     12   br label %cond.end
     13 
     14 cond.false:
     15   %sub1 = fsub fast float %a, %c
     16   br label %cond.end
     17 
     18 ; The fast-math flags should always be transfered if possible.
     19 ; CHECK-LABEL: cond.end
     20 ; CHECK  [[PHI:%[^ ]*]] = phi float [ %b, %cond.true ], [ %c, %cond.false ]
     21 ; CHECK  fsub fast float %a, [[PHI]]
     22 cond.end:
     23   %e = phi float [ %sub0, %cond.true ], [ %sub1, %cond.false ]
     24   ret float %e
     25 }
     26 
     27 ; CHECK-LABEL: define float @func2(
     28 define float @func2(float %a, float %b, float %c, i1 %cond) {
     29 entry:
     30   br i1 %cond, label %cond.true, label %cond.false
     31 
     32 cond.true:
     33   %sub0 = fsub fast float %a, %b
     34   br label %cond.end
     35 
     36 cond.false:
     37   %sub1 = fsub float %a, %c
     38   br label %cond.end
     39 
     40 ; The fast-math flags should always be transfered if possible.
     41 ; CHECK-LABEL: cond.end
     42 ; CHECK  [[PHI:%[^ ]*]] = phi float [ %b, %cond.true ], [ %c, %cond.false ]
     43 ; CHECK  fsub float %a, [[PHI]]
     44 cond.end:
     45   %e = phi float [ %sub0, %cond.true ], [ %sub1, %cond.false ]
     46   ret float %e
     47 }
     48 
     49 ; CHECK-LABEL: define float @func3(
     50 define float @func3(float %a, float %b, float %c, i1 %cond) {
     51 entry:
     52   br i1 %cond, label %cond.true, label %cond.false
     53 
     54 cond.true:
     55   %sub0 = fsub fast float %a, 2.0
     56   br label %cond.end
     57 
     58 cond.false:
     59   %sub1 = fsub fast float %b, 2.0
     60   br label %cond.end
     61 
     62 ; CHECK-LABEL: cond.end
     63 ; CHECK  [[PHI:%[^ ]*]] = phi float [ %a, %cond.true ], [ %b, %cond.false ]
     64 ; CHECK  fadd fast float %a, [[PHI]]
     65 cond.end:
     66   %e = phi float [ %sub0, %cond.true ], [ %sub1, %cond.false ]
     67   ret float %e
     68 }
     69 
     70 ; CHECK-LABEL: define float @func4(
     71 define float @func4(float %a, float %b, float %c, i1 %cond) {
     72 entry:
     73   br i1 %cond, label %cond.true, label %cond.false
     74 
     75 cond.true:
     76   %sub0 = fsub fast float %a, 2.0
     77   br label %cond.end
     78 
     79 cond.false:
     80   %sub1 = fsub float %b, 2.0
     81   br label %cond.end
     82 
     83 ; CHECK-LABEL: cond.end
     84 ; CHECK  [[PHI:%[^ ]*]] = phi float [ %a, %cond.true ], [ %b, %cond.false ]
     85 ; CHECK  fadd float %a, [[PHI]]
     86 cond.end:
     87   %e = phi float [ %sub0, %cond.true ], [ %sub1, %cond.false ]
     88   ret float %e
     89 }
     90