about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorMike Hommey <mh@glandium.org>2018-03-29 09:34:39 +0900
committerMike Hommey <mh@glandium.org>2018-03-29 09:40:55 +0900
commit262be13643cf5e3ff4f4e880b2dee601d4740fd8 (patch)
treeae9647002f9f52e91109e32117022d6f1afe3918 /src/rustllvm/RustWrapper.cpp
parente5277c1457d397f22ba18a1d40c1318729becbb4 (diff)
downloadrust-262be13643cf5e3ff4f4e880b2dee601d4740fd8.tar.gz
rust-262be13643cf5e3ff4f4e880b2dee601d4740fd8.zip
Use f{32,64}::to_bits for is_zero test in vec::SpecFromElem
vec::SpecFromElem provides an optimization to use calloc to fill a Vec
when the element given to fill the Vec is represented by 0.

For floats, the test for that currently used is `x == 0. &&
x.is_sign_positive()`. When compiled in a standalone function, rustc
generates the following assembly:

```
  xorps xmm1, xmm1
  ucomisd xmm0, xmm1
  setnp al
  sete cl
  and cl, al
  movq rax, xmm0
  test rax, rax
  setns al
  and al, cl
  ret
```

A simpler test telling us whether the value is represented by 0, is
`x.to_bits() == 0`, which rustc compiles to:

```
  movq rax, xmm0
  test rax, rax
  sete al
  ret
```

Not that the test is hot in any way, but it also makes it clearer what
the intent in the rust code is.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions