[llvm-bugs] [Bug 35233] New: fetestexcept reordered with floating point operation
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Nov 7 12:33:41 PST 2017
https://bugs.llvm.org/show_bug.cgi?id=35233
Bug ID: 35233
Summary: fetestexcept reordered with floating point operation
Product: clang
Version: 4.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: peter at trailofbits.com
CC: llvm-bugs at lists.llvm.org
Created attachment 19381
--> https://bugs.llvm.org/attachment.cgi?id=19381&action=edit
C++11 file exhibiting the bug
A static_cast of a uint64_t to a double on Clang 4.0 and AArch64 is reordered
with a fettestexcept, resulting in the wrong floating point state being tested.
Example output from GCC 6.0: https://godbolt.org/g/pbAW4J
Here's Clang's output:
oot at mcsema-aarch64:~/remill# ../remill-build/libraries/llvm/bin/clang++
-std=c++11 -O3 -c /tmp/convert.cc -S -o /tmp/convert.S
root at mcsema-aarch64:~/remill# cat /tmp/convert.S
.text
.file "/tmp/convert.cc"
.globl _Z9to_doubleR5flagsm
.p2align 2
.type _Z9to_doubleR5flagsm, at function
_Z9to_doubleR5flagsm: // @_Z9to_doubleR5flagsm
// BB#0:
stp x20, x19, [sp, #-32]! // 8-byte Folded Spill
mov x19, x0
orr w0, wzr, #0x1f
stp x29, x30, [sp, #16] // 8-byte Folded Spill
add x29, sp, #16 // =16
mov x20, x1
bl feclearexcept
orr w0, wzr, #0x1f
bl fetestexcept
tbz w0, #4, .LBB0_2
// BB#1:
orr w8, wzr, #0x1
str w8, [x19]
.LBB0_2:
tbz w0, #2, .LBB0_4
// BB#3:
orr w8, wzr, #0x1
str w8, [x19, #4]
.LBB0_4:
tbz w0, #3, .LBB0_6
// BB#5:
orr w8, wzr, #0x1
str w8, [x19, #8]
.LBB0_6:
ucvtf d0, x20
tbz w0, #0, .LBB0_8
// BB#7:
orr w8, wzr, #0x1
str w8, [x19, #12]
.LBB0_8:
ldp x29, x30, [sp, #16] // 8-byte Folded Reload
ldp x20, x19, [sp], #32 // 8-byte Folded Reload
ret
.Lfunc_end0:
.size _Z9to_doubleR5flagsm, .Lfunc_end0-_Z9to_doubleR5flagsm
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171107/ff037b6d/attachment.html>
More information about the llvm-bugs
mailing list