[llvm] [GVN] Freeze value if `undef` when forwarding local memset to loads (PR #91376)
Nuno Lopes via llvm-commits
llvm-commits at lists.llvm.org
Wed May 8 03:49:38 PDT 2024
nunoplopes wrote:
This depends on the semantics of memset.
There are two possibilities:
```c
memset(ptr, val, size)
=>
for (i = 0; i < size; ++i)
ptr[i] = val;
```
or
```c
tmp = freeze(val)
for (i = 0; i < size; ++i)
ptr[i] = tmp;
```
Alive2 implements the second semantics because it feels strange that memset can write a different value to each byte.
The first version gives more flexibility for lowering memset, though. For C/C++, I think either of the semantics works, as undef comes from reading uninitialized values only.
FWIW, implementing the first semantics in Alive2 is not trivial and would come with terrible performance. I think that's also something to keep in mind if we want to adopt a verification tool in our workflow.
https://github.com/llvm/llvm-project/pull/91376
More information about the llvm-commits
mailing list