blob: 9fe7a3bfcbb708a06b3f68c877807430a5ceaf1d [file] [log] [blame]
Ehsan Amiria538b0f2016-08-03 18:17:35 +00001; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mattr=-fpcvt < %s | FileCheck %s
Tony Jiang8e8c4442017-01-16 20:12:26 +00002; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mattr=-fpcvt -ppc-gen-isel=false < %s | FileCheck %s --check-prefix=CHECK-NO-ISEL
Ulrich Weigandd34b5bd2012-10-18 13:16:11 +00003target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v128:128:128-n32:64"
4target triple = "powerpc64-unknown-linux-gnu"
5
6define float @test(i64 %x) nounwind readnone {
7entry:
8 %conv = sitofp i64 %x to float
9 ret float %conv
10}
11
12; Verify that we get the code sequence needed to avoid double-rounding.
13; Note that only parts of the sequence are checked for here, to allow
14; for minor code generation differences.
15
Tony Jiang8e8c4442017-01-16 20:12:26 +000016;CHECK-LABEL: test
17;CHECK-NO-ISEL-LABEL: test
Eli Benderskyeaf1a282012-11-26 14:09:46 +000018; CHECK: sradi [[REG1:[0-9]+]], 3, 53
19; CHECK: addi [[REG2:[0-9]+]], [[REG1]], 1
Hal Finkel7c5cb062015-04-23 18:30:38 +000020; CHECK: cmpldi [[REG2]], 1
Eli Benderskyeaf1a282012-11-26 14:09:46 +000021; CHECK: isel [[REG3:[0-9]+]], {{[0-9]+}}, 3, 1
Nemanja Ivanovic82d53ed2017-02-24 18:03:16 +000022; CHECK-NO-ISEL: rldicr [[REG2:[0-9]+]], {{[0-9]+}}, 0, 52
Tony Jiang8e8c4442017-01-16 20:12:26 +000023; CHECK-NO-ISEL: bc 12, 1, [[TRUE:.LBB[0-9]+]]
Nemanja Ivanovic82d53ed2017-02-24 18:03:16 +000024; CHECK-NO-ISEL: ori [[REG3:[0-9]+]], 3, 0
Tony Jiang8e8c4442017-01-16 20:12:26 +000025; CHECK-NO-ISEL-NEXT: b [[SUCCESSOR:.LBB[0-9]+]]
26; CHECK-NO-ISEL-NEXT: [[TRUE]]
Nemanja Ivanovic82d53ed2017-02-24 18:03:16 +000027; CHECK-NO-ISEL-NEXT: addi [[REG3]], [[REG2]], 0
28; CHECK-NO-ISEL-NEXT: [[SUCCESSOR]]
29; CHECK-NO-ISEL: std [[REG3]], -{{[0-9]+}}(1)
Eli Benderskyeaf1a282012-11-26 14:09:46 +000030; CHECK: std [[REG3]], -{{[0-9]+}}(1)
Ulrich Weigandd34b5bd2012-10-18 13:16:11 +000031
32
33; Also check that with -enable-unsafe-fp-math we do not get that extra
34; code sequence. Simply verify that there is no "isel" present.
35
Ehsan Amiria538b0f2016-08-03 18:17:35 +000036; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mattr=-fpcvt -enable-unsafe-fp-math < %s | FileCheck %s -check-prefix=CHECK-UNSAFE
Ulrich Weigandd34b5bd2012-10-18 13:16:11 +000037; CHECK-UNSAFE-NOT: isel
38