Home | History | Annotate | Download | only in LICM
      1 ; RUN: opt -S -licm < %s | FileCheck %s
      2 ; RUN: opt -aa-pipeline=basic-aa -passes='require<aa>,require<targetir>,require<scalar-evolution>,loop(licm)' -S %s | FileCheck %s
      3 
      4 target datalayout = "E-m:e-p:32:32-i8:8:8-i16:16:16-i64:32:32-f64:32:32-v64:32:32-v128:32:32-a0:0:32-n32"
      5 
      6 ; This test verifies that ceil, floor, nearbyint, trunc, rint, round,
      7 ; copysign, minnum, maxnum and fabs intrinsics are considered safe
      8 ; to speculate.
      9 
     10 ; CHECK-LABEL: @test
     11 ; CHECK: call float @llvm.ceil.f32
     12 ; CHECK: call float @llvm.floor.f32
     13 ; CHECK: call float @llvm.nearbyint.f32
     14 ; CHECK: call float @llvm.rint.f32
     15 ; CHECK: call float @llvm.round.f32
     16 ; CHECK: call float @llvm.trunc.f32
     17 ; CHECK: call float @llvm.fabs.f32
     18 ; CHECK: call float @llvm.copysign.f32
     19 ; CHECK: call float @llvm.minnum.f32
     20 ; CHECK: call float @llvm.maxnum.f32
     21 ; CHECK: for.body:
     22 
     23 define void @test(float %arg1, float %arg2) {
     24 entry:
     25   br label %for.head
     26 
     27 for.head:
     28   %IND = phi i32 [ 0, %entry ], [ %IND.new, %for.body ]
     29   %CMP = icmp slt i32 %IND, 10
     30   br i1 %CMP, label %for.body, label %exit
     31 
     32 for.body:
     33   %tmp.1 = call float @llvm.ceil.f32(float %arg1)
     34   %tmp.2 = call float @llvm.floor.f32(float %tmp.1)
     35   %tmp.3 = call float @llvm.nearbyint.f32(float %tmp.2)
     36   %tmp.4 = call float @llvm.rint.f32(float %tmp.3)
     37   %tmp.5 = call float @llvm.round.f32(float %tmp.4)
     38   %tmp.6 = call float @llvm.trunc.f32(float %tmp.5)
     39   %tmp.7 = call float @llvm.fabs.f32(float %tmp.6)
     40   %tmp.8 = call float @llvm.copysign.f32(float %tmp.7, float %arg2)
     41   %tmp.9 = call float @llvm.minnum.f32(float %tmp.8, float %arg2)
     42   %tmp.10 = call float @llvm.maxnum.f32(float %tmp.9, float %arg2)
     43   call void @consume(float %tmp.10)
     44   %IND.new = add i32 %IND, 1
     45   br label %for.head
     46 
     47 exit:
     48   ret void
     49 }
     50 
     51 declare void @consume(float)
     52 
     53 declare float @llvm.ceil.f32(float)
     54 declare float @llvm.floor.f32(float)
     55 declare float @llvm.nearbyint.f32(float)
     56 declare float @llvm.rint.f32(float)
     57 declare float @llvm.round.f32(float)
     58 declare float @llvm.trunc.f32(float)
     59 declare float @llvm.fabs.f32(float)
     60 declare float @llvm.copysign.f32(float, float)
     61 declare float @llvm.minnum.f32(float, float)
     62 declare float @llvm.maxnum.f32(float, float)
     63