2014-04-15 14:00:29 +00:00
|
|
|
; RUN: llc -mtriple=aarch64-none-linux-gnu -verify-machineinstrs < %s | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-AARCH64
|
2014-04-15 19:08:46 +00:00
|
|
|
; RUN: llc -mtriple=arm64-none-linux-gnu -mcpu=cyclone -verify-machineinstrs -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-ARM64
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
@lhs = global fp128 zeroinitializer
|
|
|
|
@rhs = global fp128 zeroinitializer
|
|
|
|
|
|
|
|
define fp128 @test_add() {
|
2013-07-13 20:38:47 +00:00
|
|
|
; CHECK-LABEL: test_add:
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
%lhs = load fp128* @lhs
|
|
|
|
%rhs = load fp128* @rhs
|
2014-04-15 14:00:29 +00:00
|
|
|
; CHECK: ldr q0, [{{x[0-9]+}}, {{#?}}:lo12:lhs]
|
|
|
|
; CHECK: ldr q1, [{{x[0-9]+}}, {{#?}}:lo12:rhs]
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
%val = fadd fp128 %lhs, %rhs
|
|
|
|
; CHECK: bl __addtf3
|
|
|
|
ret fp128 %val
|
|
|
|
}
|
|
|
|
|
|
|
|
define fp128 @test_sub() {
|
2013-07-13 20:38:47 +00:00
|
|
|
; CHECK-LABEL: test_sub:
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
%lhs = load fp128* @lhs
|
|
|
|
%rhs = load fp128* @rhs
|
2014-04-15 14:00:29 +00:00
|
|
|
; CHECK: ldr q0, [{{x[0-9]+}}, {{#?}}:lo12:lhs]
|
|
|
|
; CHECK: ldr q1, [{{x[0-9]+}}, {{#?}}:lo12:rhs]
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
%val = fsub fp128 %lhs, %rhs
|
|
|
|
; CHECK: bl __subtf3
|
|
|
|
ret fp128 %val
|
|
|
|
}
|
|
|
|
|
|
|
|
define fp128 @test_mul() {
|
2013-07-13 20:38:47 +00:00
|
|
|
; CHECK-LABEL: test_mul:
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
%lhs = load fp128* @lhs
|
|
|
|
%rhs = load fp128* @rhs
|
2014-04-15 14:00:29 +00:00
|
|
|
; CHECK: ldr q0, [{{x[0-9]+}}, {{#?}}:lo12:lhs]
|
|
|
|
; CHECK: ldr q1, [{{x[0-9]+}}, {{#?}}:lo12:rhs]
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
%val = fmul fp128 %lhs, %rhs
|
|
|
|
; CHECK: bl __multf3
|
|
|
|
ret fp128 %val
|
|
|
|
}
|
|
|
|
|
|
|
|
define fp128 @test_div() {
|
2013-07-13 20:38:47 +00:00
|
|
|
; CHECK-LABEL: test_div:
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
%lhs = load fp128* @lhs
|
|
|
|
%rhs = load fp128* @rhs
|
2014-04-15 14:00:29 +00:00
|
|
|
; CHECK: ldr q0, [{{x[0-9]+}}, {{#?}}:lo12:lhs]
|
|
|
|
; CHECK: ldr q1, [{{x[0-9]+}}, {{#?}}:lo12:rhs]
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
%val = fdiv fp128 %lhs, %rhs
|
|
|
|
; CHECK: bl __divtf3
|
|
|
|
ret fp128 %val
|
|
|
|
}
|
|
|
|
|
|
|
|
@var32 = global i32 0
|
|
|
|
@var64 = global i64 0
|
|
|
|
|
|
|
|
define void @test_fptosi() {
|
2013-07-13 20:38:47 +00:00
|
|
|
; CHECK-LABEL: test_fptosi:
|
2013-01-31 12:12:40 +00:00
|
|
|
%val = load fp128* @lhs
|
|
|
|
|
|
|
|
%val32 = fptosi fp128 %val to i32
|
|
|
|
store i32 %val32, i32* @var32
|
|
|
|
; CHECK: bl __fixtfsi
|
|
|
|
|
|
|
|
%val64 = fptosi fp128 %val to i64
|
|
|
|
store i64 %val64, i64* @var64
|
|
|
|
; CHECK: bl __fixtfdi
|
|
|
|
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @test_fptoui() {
|
2013-07-13 20:38:47 +00:00
|
|
|
; CHECK-LABEL: test_fptoui:
|
2013-01-31 12:12:40 +00:00
|
|
|
%val = load fp128* @lhs
|
|
|
|
|
|
|
|
%val32 = fptoui fp128 %val to i32
|
|
|
|
store i32 %val32, i32* @var32
|
|
|
|
; CHECK: bl __fixunstfsi
|
|
|
|
|
|
|
|
%val64 = fptoui fp128 %val to i64
|
|
|
|
store i64 %val64, i64* @var64
|
|
|
|
; CHECK: bl __fixunstfdi
|
|
|
|
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @test_sitofp() {
|
2013-07-13 20:38:47 +00:00
|
|
|
; CHECK-LABEL: test_sitofp:
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
%src32 = load i32* @var32
|
|
|
|
%val32 = sitofp i32 %src32 to fp128
|
|
|
|
store volatile fp128 %val32, fp128* @lhs
|
|
|
|
; CHECK: bl __floatsitf
|
|
|
|
|
|
|
|
%src64 = load i64* @var64
|
|
|
|
%val64 = sitofp i64 %src64 to fp128
|
|
|
|
store volatile fp128 %val64, fp128* @lhs
|
|
|
|
; CHECK: bl __floatditf
|
|
|
|
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @test_uitofp() {
|
2013-07-13 20:38:47 +00:00
|
|
|
; CHECK-LABEL: test_uitofp:
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
%src32 = load i32* @var32
|
|
|
|
%val32 = uitofp i32 %src32 to fp128
|
|
|
|
store volatile fp128 %val32, fp128* @lhs
|
|
|
|
; CHECK: bl __floatunsitf
|
|
|
|
|
|
|
|
%src64 = load i64* @var64
|
|
|
|
%val64 = uitofp i64 %src64 to fp128
|
|
|
|
store volatile fp128 %val64, fp128* @lhs
|
|
|
|
; CHECK: bl __floatunditf
|
|
|
|
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @test_setcc1() {
|
2013-07-13 20:38:47 +00:00
|
|
|
; CHECK-LABEL: test_setcc1:
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
%lhs = load fp128* @lhs
|
|
|
|
%rhs = load fp128* @rhs
|
2014-04-15 14:00:29 +00:00
|
|
|
; CHECK: ldr q0, [{{x[0-9]+}}, {{#?}}:lo12:lhs]
|
|
|
|
; CHECK: ldr q1, [{{x[0-9]+}}, {{#?}}:lo12:rhs]
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
; Technically, everything after the call to __letf2 is redundant, but we'll let
|
|
|
|
; LLVM have its fun for now.
|
|
|
|
%val = fcmp ole fp128 %lhs, %rhs
|
|
|
|
; CHECK: bl __letf2
|
|
|
|
; CHECK: cmp w0, #0
|
|
|
|
; CHECK: csinc w0, wzr, wzr, gt
|
|
|
|
|
|
|
|
ret i1 %val
|
|
|
|
; CHECK: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @test_setcc2() {
|
2013-07-13 20:38:47 +00:00
|
|
|
; CHECK-LABEL: test_setcc2:
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
%lhs = load fp128* @lhs
|
|
|
|
%rhs = load fp128* @rhs
|
2014-04-15 14:00:29 +00:00
|
|
|
; CHECK: ldr q0, [{{x[0-9]+}}, {{#?}}:lo12:lhs]
|
|
|
|
; CHECK: ldr q1, [{{x[0-9]+}}, {{#?}}:lo12:rhs]
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
; Technically, everything after the call to __letf2 is redundant, but we'll let
|
|
|
|
; LLVM have its fun for now.
|
|
|
|
%val = fcmp ugt fp128 %lhs, %rhs
|
|
|
|
; CHECK: bl __gttf2
|
|
|
|
; CHECK: cmp w0, #0
|
|
|
|
; CHECK: csinc [[GT:w[0-9]+]], wzr, wzr, le
|
2013-10-09 07:53:57 +00:00
|
|
|
|
|
|
|
; CHECK: bl __unordtf2
|
|
|
|
; CHECK: cmp w0, #0
|
2013-01-31 12:12:40 +00:00
|
|
|
; CHECK: csinc [[UNORDERED:w[0-9]+]], wzr, wzr, eq
|
2013-10-09 07:53:57 +00:00
|
|
|
|
2013-01-31 12:12:40 +00:00
|
|
|
; CHECK: orr w0, [[UNORDERED]], [[GT]]
|
|
|
|
|
|
|
|
ret i1 %val
|
|
|
|
; CHECK: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test_br_cc() {
|
2013-07-13 20:38:47 +00:00
|
|
|
; CHECK-LABEL: test_br_cc:
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
%lhs = load fp128* @lhs
|
|
|
|
%rhs = load fp128* @rhs
|
2014-04-15 14:00:29 +00:00
|
|
|
; CHECK: ldr q0, [{{x[0-9]+}}, {{#?}}:lo12:lhs]
|
|
|
|
; CHECK: ldr q1, [{{x[0-9]+}}, {{#?}}:lo12:rhs]
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
; olt == !uge, which LLVM unfortunately "optimizes" this to.
|
|
|
|
%cond = fcmp olt fp128 %lhs, %rhs
|
|
|
|
; CHECK: bl __getf2
|
|
|
|
; CHECK: cmp w0, #0
|
|
|
|
; CHECK: csinc [[OGE:w[0-9]+]], wzr, wzr, lt
|
2013-10-09 07:53:57 +00:00
|
|
|
|
|
|
|
; CHECK: bl __unordtf2
|
|
|
|
; CHECK: cmp w0, #0
|
2013-01-31 12:12:40 +00:00
|
|
|
; CHECK: csinc [[UNORDERED:w[0-9]+]], wzr, wzr, eq
|
2013-10-09 07:53:57 +00:00
|
|
|
|
2013-01-31 12:12:40 +00:00
|
|
|
; CHECK: orr [[UGE:w[0-9]+]], [[UNORDERED]], [[OGE]]
|
|
|
|
; CHECK: cbnz [[UGE]], [[RET29:.LBB[0-9]+_[0-9]+]]
|
|
|
|
br i1 %cond, label %iftrue, label %iffalse
|
|
|
|
|
|
|
|
iftrue:
|
|
|
|
ret i32 42
|
|
|
|
; CHECK-NEXT: BB#
|
2014-04-15 14:00:29 +00:00
|
|
|
; CHECK-NEXT: movz {{x0|w0}}, #42
|
2013-01-31 12:12:40 +00:00
|
|
|
; CHECK-NEXT: b [[REALRET:.LBB[0-9]+_[0-9]+]]
|
|
|
|
|
|
|
|
iffalse:
|
|
|
|
ret i32 29
|
|
|
|
; CHECK: [[RET29]]:
|
2014-04-15 14:00:29 +00:00
|
|
|
; CHECK-NEXT: movz {{x0|w0}}, #29
|
2013-01-31 12:12:40 +00:00
|
|
|
; CHECK-NEXT: [[REALRET]]:
|
|
|
|
; CHECK: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @test_select(i1 %cond, fp128 %lhs, fp128 %rhs) {
|
2013-07-13 20:38:47 +00:00
|
|
|
; CHECK-LABEL: test_select:
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
%val = select i1 %cond, fp128 %lhs, fp128 %rhs
|
|
|
|
store fp128 %val, fp128* @lhs
|
2014-04-15 14:00:29 +00:00
|
|
|
; CHECK: cmp {{w[0-9]+}}, #0
|
|
|
|
; CHECK-AARCH64: str q1, [sp]
|
2013-01-31 12:12:40 +00:00
|
|
|
; CHECK-NEXT: b.eq [[IFFALSE:.LBB[0-9]+_[0-9]+]]
|
|
|
|
; CHECK-NEXT: BB#
|
2014-04-15 14:00:29 +00:00
|
|
|
; CHECK-AARCH64-NEXT: str q0, [sp]
|
|
|
|
; CHECK-ARM64-NEXT: orr v[[DEST:[0-9]+]].16b, v0.16b, v0.16b
|
2013-01-31 12:12:40 +00:00
|
|
|
; CHECK-NEXT: [[IFFALSE]]:
|
2014-04-15 14:00:29 +00:00
|
|
|
; CHECK-AARCH64-NEXT: ldr q[[DEST:[0-9]+]], [sp]
|
|
|
|
; CHECK: str q[[DEST]], [{{x[0-9]+}}, {{#?}}:lo12:lhs]
|
2013-01-31 12:12:40 +00:00
|
|
|
ret void
|
|
|
|
; CHECK: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
@varfloat = global float 0.0
|
|
|
|
@vardouble = global double 0.0
|
|
|
|
|
|
|
|
define void @test_round() {
|
2013-07-13 20:38:47 +00:00
|
|
|
; CHECK-LABEL: test_round:
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
%val = load fp128* @lhs
|
|
|
|
|
|
|
|
%float = fptrunc fp128 %val to float
|
|
|
|
store float %float, float* @varfloat
|
|
|
|
; CHECK: bl __trunctfsf2
|
2014-04-15 14:00:29 +00:00
|
|
|
; CHECK: str s0, [{{x[0-9]+}}, {{#?}}:lo12:varfloat]
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
%double = fptrunc fp128 %val to double
|
|
|
|
store double %double, double* @vardouble
|
|
|
|
; CHECK: bl __trunctfdf2
|
2014-04-15 14:00:29 +00:00
|
|
|
; CHECK: str d0, [{{x[0-9]+}}, {{#?}}:lo12:vardouble]
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @test_extend() {
|
2013-07-13 20:38:47 +00:00
|
|
|
; CHECK-LABEL: test_extend:
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
%val = load fp128* @lhs
|
|
|
|
|
|
|
|
%float = load float* @varfloat
|
|
|
|
%fromfloat = fpext float %float to fp128
|
|
|
|
store volatile fp128 %fromfloat, fp128* @lhs
|
|
|
|
; CHECK: bl __extendsftf2
|
2014-04-15 14:00:29 +00:00
|
|
|
; CHECK: str q0, [{{x[0-9]+}}, {{#?}}:lo12:lhs]
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
%double = load double* @vardouble
|
|
|
|
%fromdouble = fpext double %double to fp128
|
|
|
|
store volatile fp128 %fromdouble, fp128* @lhs
|
|
|
|
; CHECK: bl __extenddftf2
|
2014-04-15 14:00:29 +00:00
|
|
|
; CHECK: str q0, [{{x[0-9]+}}, {{#?}}:lo12:lhs]
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
ret void
|
|
|
|
; CHECK: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
define fp128 @test_neg(fp128 %in) {
|
2013-02-15 09:33:43 +00:00
|
|
|
; CHECK: [[MINUS0:.LCPI[0-9]+_0]]:
|
|
|
|
; Make sure the weird hex constant below *is* -0.0
|
|
|
|
; CHECK-NEXT: fp128 -0
|
|
|
|
|
2013-07-13 20:38:47 +00:00
|
|
|
; CHECK-LABEL: test_neg:
|
2013-01-31 12:12:40 +00:00
|
|
|
|
|
|
|
; Could in principle be optimized to fneg which we can't select, this makes
|
|
|
|
; sure that doesn't happen.
|
|
|
|
%ret = fsub fp128 0xL00000000000000008000000000000000, %in
|
2014-04-15 14:00:29 +00:00
|
|
|
; CHECK-AARCH64: str q0, [sp, #-16]
|
|
|
|
; CHECK-AARCH64-NEXT: ldr q1, [sp], #16
|
|
|
|
; CHECK-ARM64: orr v1.16b, v0.16b, v0.16b
|
|
|
|
; CHECK: ldr q0, [{{x[0-9]+}}, {{#?}}:lo12:[[MINUS0]]]
|
2013-01-31 12:12:40 +00:00
|
|
|
; CHECK: bl __subtf3
|
|
|
|
|
|
|
|
ret fp128 %ret
|
|
|
|
; CHECK: ret
|
|
|
|
}
|