1 ; Test that the exp2 library call simplifier works correctly.
3 ; RUN: opt < %s -instcombine -S | FileCheck %s -check-prefix=CHECK -check-prefix=INTRINSIC -check-prefix=LDEXP -check-prefix=LDEXPF
4 ; RUN: opt < %s -instcombine -S -mtriple=i386-pc-win32 | FileCheck %s -check-prefix=INTRINSIC -check-prefix=LDEXP -check-prefix=NOLDEXPF
5 ; RUN: opt < %s -instcombine -S -mtriple=amdgcn-unknown-unknown | FileCheck %s -check-prefix=INTRINSIC -check-prefix=NOLDEXP -check-prefix=NOLDEXPF
7 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
9 declare double @exp2(double)
10 declare float @exp2f(float)
12 ; Check exp2(sitofp(x)) -> ldexp(1.0, sext(x)).
14 define double @test_simplify1(i32 %x) {
15 ; CHECK-LABEL: @test_simplify1(
16 %conv = sitofp i32 %x to double
17 %ret = call double @exp2(double %conv)
18 ; CHECK: call double @ldexp
22 define double @test_simplify2(i16 signext %x) {
23 ; CHECK-LABEL: @test_simplify2(
24 %conv = sitofp i16 %x to double
25 %ret = call double @exp2(double %conv)
26 ; CHECK: call double @ldexp
30 define double @test_simplify3(i8 signext %x) {
31 ; CHECK-LABEL: @test_simplify3(
32 %conv = sitofp i8 %x to double
33 %ret = call double @exp2(double %conv)
34 ; CHECK: call double @ldexp
38 define float @test_simplify4(i32 %x) {
39 ; CHECK-LABEL: @test_simplify4(
40 %conv = sitofp i32 %x to float
41 %ret = call float @exp2f(float %conv)
42 ; CHECK: call float @ldexpf
46 ; Check exp2(uitofp(x)) -> ldexp(1.0, zext(x)).
48 define double @test_no_simplify1(i32 %x) {
49 ; CHECK-LABEL: @test_no_simplify1(
50 %conv = uitofp i32 %x to double
51 %ret = call double @exp2(double %conv)
52 ; CHECK: call double @exp2
56 define double @test_simplify6(i16 zeroext %x) {
57 ; CHECK-LABEL: @test_simplify6(
58 %conv = uitofp i16 %x to double
59 %ret = call double @exp2(double %conv)
60 ; CHECK: call double @ldexp
64 define double @test_simplify7(i8 zeroext %x) {
65 ; CHECK-LABEL: @test_simplify7(
66 %conv = uitofp i8 %x to double
67 %ret = call double @exp2(double %conv)
68 ; CHECK: call double @ldexp
72 define float @test_simplify8(i8 zeroext %x) {
73 ; CHECK-LABEL: @test_simplify8(
74 %conv = uitofp i8 %x to float
75 %ret = call float @exp2f(float %conv)
76 ; CHECK: call float @ldexpf
80 declare double @llvm.exp2.f64(double)
81 declare float @llvm.exp2.f32(float)
83 define double @test_simplify9(i8 zeroext %x) {
84 ; INTRINSIC-LABEL: @test_simplify9(
85 %conv = uitofp i8 %x to double
86 %ret = call double @llvm.exp2.f64(double %conv)
87 ; LDEXP: call double @ldexp
88 ; NOLDEXP-NOT: call double @ldexp
92 define float @test_simplify10(i8 zeroext %x) {
93 ; INTRINSIC-LABEL: @test_simplify10(
94 %conv = uitofp i8 %x to float
95 %ret = call float @llvm.exp2.f32(float %conv)
96 ; LDEXPF: call float @ldexpf
97 ; NOLDEXPF-NOT: call float @ldexpf