(original) (raw)
Hi all,
Is it possible to use \_\_builtin\_assume (or something similar like \_\_builtin\_unreachable) to eliminate stores?
Eg I would expect that I if I write something as follows the optimizer could optimize away the store to the variable a:
void foo(int\* a)
{
\_\_builtin\_assume(\*a == 0);
\*a = 0;
}
But the generated code still writes to the variable:
; Function Attrs: nounwind uwtable
define void @\_Z3fooPi(i32\* nocapture %a) #0 {
%1 = load i32, i32\* %a, align 4, !tbaa !8
%2 = icmp eq i32 %1, 0
tail call void @llvm.assume(i1 %2)
store i32 0, i32\* %a, align 4, !tbaa !8
ret void
}
00000000000000a0 <\_Z3fooPi>:
a0: c7 07 00 00 00 00 movl $0x0,(%rdi)
a6: c3 retq
Why this store not optimized away?
Is there another way to tell the optimizer that the store can be eliminated?
Regards,
Tom