# libc: Prevent FCSEL instruction from being used to avoid raising an unintended exception · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/878b7b80c15d4b9a894f6ab1d4e8753de77568ad)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 878b7b80c15d4b9a894f6ab1d4e8753de77568ad

Requested commit: 878b7b80c15d4b9a894f6ab1d4e8753de77568ad

Commit: 878b7b80c15d4b9a894f6ab1d4e8753de77568ad

Tree: db26c68ae9e0da28fefba8c0b2b2f917655bbbdb

Author: Koki Ueha

Committer: Jacob Young

## Message

```
libc: Prevent FCSEL instruction from being used to avoid raising an unintended exception

If you write an if expression in mem.doNotOptimizeAway like
doNotOptimizeAway(if (ix < 0x00100000) x / 0x1p120 else x + 0x1p120);,
FCSEL instruction is used on AArch64.
FCSEL instruction selects one of the two registers according to
the condition and copies its value.
In this example, `x / 0x1p120` and `x + 0x1p120` are expressions
that raise different floating-point exceptions.
However, since both are actually evaluated before the FCSEL
instruction, the exception not intended by the programmer may
also be raised.

To prevent FCSEL instruction from being used here, this commit
splits doNotOptimizeAway in two.

```

## Parents

- [3ce8d19f76690afe21b77651cffef9a9866cbf30](https://git.cafe/gitcafe/zig/commit/3ce8d19f76690afe21b77651cffef9a9866cbf30?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/878b7b80c15d4b9a894f6ab1d4e8753de77568ad?format=markdown)
