1 ; Test that the exp2 library call simplifier works correctly.
3 ; RUN: opt < %s -instcombine -S | FileCheck %s
5 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"
7 declare double @exp2(double)
8 declare float @exp2f(float)
10 ; Check exp2(sitofp(x)) -> ldexp(1.0, sext(x)).
12 define double @test_simplify1(i32 %x) {
13 ; CHECK-LABEL: @test_simplify1(
14 %conv = sitofp i32 %x to double
15 %ret = call double @exp2(double %conv)
16 ; CHECK: call double @ldexp
20 define double @test_simplify2(i16 signext %x) {
21 ; CHECK-LABEL: @test_simplify2(
22 %conv = sitofp i16 %x to double
23 %ret = call double @exp2(double %conv)
24 ; CHECK: call double @ldexp
28 define double @test_simplify3(i8 signext %x) {
29 ; CHECK-LABEL: @test_simplify3(
30 %conv = sitofp i8 %x to double
31 %ret = call double @exp2(double %conv)
32 ; CHECK: call double @ldexp
36 define float @test_simplify4(i32 %x) {
37 ; CHECK-LABEL: @test_simplify4(
38 %conv = sitofp i32 %x to float
39 %ret = call float @exp2f(float %conv)
40 ; CHECK: call float @ldexpf
44 ; Check exp2(uitofp(x)) -> ldexp(1.0, zext(x)).
46 define double @test_no_simplify1(i32 %x) {
47 ; CHECK-LABEL: @test_no_simplify1(
48 %conv = uitofp i32 %x to double
49 %ret = call double @exp2(double %conv)
50 ; CHECK: call double @exp2
54 define double @test_simplify6(i16 zeroext %x) {
55 ; CHECK-LABEL: @test_simplify6(
56 %conv = uitofp i16 %x to double
57 %ret = call double @exp2(double %conv)
58 ; CHECK: call double @ldexp
62 define double @test_simplify7(i8 zeroext %x) {
63 ; CHECK-LABEL: @test_simplify7(
64 %conv = uitofp i8 %x to double
65 %ret = call double @exp2(double %conv)
66 ; CHECK: call double @ldexp
70 define float @test_simplify8(i8 zeroext %x) {
71 ; CHECK-LABEL: @test_simplify8(
72 %conv = uitofp i8 %x to float
73 %ret = call float @exp2f(float %conv)
74 ; CHECK: call float @ldexpf