1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-23 13:02:52 +02:00
llvm-mirror/test/CodeGen/Generic/pr24662.ll
Simon Pilgrim 8e3c60968e Fix constant folding of fp2int to large integers
We make the assumption in most of our constant folding code that a fp2int will target an integer of 128-bits or less, calling the APFloat::convertToInteger with only uint64_t[2] of raw bits for the result.

Fuzz testing (PR24662) showed that we don't handle other cases at all, resulting in stack overflows and all sorts of crashes.

This patch uses the APSInt version of APFloat::convertToInteger instead to better handle such cases.

Differential Revision: https://reviews.llvm.org/D31074

llvm-svn: 298226
2017-03-19 16:50:25 +00:00

13 lines
270 B
LLVM

; RUN: llc < %s -fast-isel
; RUN: llc < %s
define i60 @PR24662a() {
ret i60 trunc (i670010 fptoui(float 0x400D9999A0000000 to i670010) to i60)
}
define i60 @PR24662b() {
%1 = fptoui float 0x400D9999A0000000 to i670010
%2 = trunc i670010 %1 to i60
ret i60 %2
}