https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85957
--- Comment #21 from Alexander Cherepanov <ch3root at openwall dot com> ---
The following variation works with the trunk:
----------------------------------------------------------------------
#include <stdio.h>
__attribute__((noipa)) // imagine it in a separate TU
static int opaque(int i) { return i; }
int main()
{
static int a = 0;
int d = opaque(1);
if (opaque(0))
puts("ignore");
// need the next `if` to be at the start of a BB
if (d == 1)
a = 1;
int i = d - 0x1p-60;
if (i == 1)
printf("i = %d\n", i);
printf("i = %d\n", i);
opaque(a);
}
----------------------------------------------------------------------
$ gcc -std=gnu11 -pedantic -Wall -Wextra -m32 -march=i686 -O3 test.c && ./a.out
i = 1
i = 0
----------------------------------------------------------------------
gcc x86-64 version: gcc (GCC) 10.0.1 20200211 (experimental)
----------------------------------------------------------------------
All the same but the computation of `i` is hoisted from the `if` in the
133t.pre pass so dom3 doesn't have a chance to fold it.
Another interesting aspect: there are no comparisons of floating-point numbers
in this example, all FP operations are limited to a basic arithmetic and a
conversion.