[LLVMdev] Eliminate stores with __builtin_assume (original) (raw)
Tom Aernoudt Tom.Aernoudt at synopsys.com
Fri Jul 3 03:55:54 PDT 2015
- Previous message: [LLVMdev] MCInstrInfo::hasDefOfPhysReg() now private?
- Next message: [LLVMdev] Eliminate stores with __builtin_assume
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150703/c13e2b35/attachment.html>
- Previous message: [LLVMdev] MCInstrInfo::hasDefOfPhysReg() now private?
- Next message: [LLVMdev] Eliminate stores with __builtin_assume
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]