Open
Description
The code:
void f(int x, int a, int b) {
ext(__builtin_nondeterministic_value(5), a, b);
}
gets optimized to ext(0, a, b);
, thus ending up with an unnecessary zeroing of a register. IR-wise, a freeze i32 poison
becomes 0
during instcombine. https://godbolt.org/z/6rxsdr634
This means that __builtin_nondeterministic_value
is unsuitable for efficiently calling a function where the caller knows that the callee won't use some argument(s). The only option that roughly works that I've found is to read an uninitialized variable, but that produces a warning and breaks under memorysanitizer.
Passing the pre-instcombine IR directly to the backend generates the desired assembly: https://godbolt.org/z/on6W17ex4