Carlo Alberto Ferraris
2011-Jul-07 09:05 UTC
[LLVMdev] Missed optimization with indirectbr terminator
Consider this IR fragment produced after -O3:> %7: > %8 = phi i8* [ blockaddress(@0, %19), %19 ], [ %12, %11 ] > %9 = phi i32 [ %20, %19 ], [ 0, %11 ] > indirectbr i8* %8, [label %4, label %19] > > %19: > %20 = add nsw i32 %9, 1 > %21 = icmp eq i32 %9, 9999 > br i1 %21, label %16, label %7the br in %19 should be optimized to branch directly to itself rather than going back to %7 (note that the arg %8 to the indirectbr will always be the address of %19 when coming from %19). Is this a known missed optimization? -- Carlo Alberto Ferraris <cafxx at strayorange.com <mailto:cafxx at strayorange.com>> website/blog <http://cafxx.strayorange.com> - +39 333 7643 235 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110707/79866d0b/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: cafxx.vcf Type: text/x-vcard Size: 233 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110707/79866d0b/attachment.vcf>
Cameron Zwarich
2011-Jul-07 09:14 UTC
[LLVMdev] Missed optimization with indirectbr terminator
On Jul 7, 2011, at 2:05 AM, Carlo Alberto Ferraris wrote:> Consider this IR fragment produced after -O3: >> %7: >> %8 = phi i8* [ blockaddress(@0, %19), %19 ], [ %12, %11 ] >> %9 = phi i32 [ %20, %19 ], [ 0, %11 ] >> indirectbr i8* %8, [label %4, label %19] >> >> %19: >> %20 = add nsw i32 %9, 1 >> %21 = icmp eq i32 %9, 9999 >> br i1 %21, label %16, label %7 > the br in %19 should be optimized to branch directly to itself rather than going back to %7 (note that the arg %8 to the indirectbr will always be the address of %19 when coming from %19). > Is this a known missed optimization?I haven't read the code in detail, but it looks like JumpThreading at least attempts to thread across indirect branches. You can either try to fix it or file a bug with your test case. Cameron -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110707/b782a1d6/attachment.html>
Carlo Alberto Ferraris
2011-Jul-07 11:33 UTC
[LLVMdev] Missed optimization with indirectbr terminator
Il 07/07/2011 11:14, Cameron Zwarich ha scritto:> I haven't read the code in detail, but it looks like JumpThreading at > least attempts to thread across indirect branches. You can either try > to fix it or file a bug with your test case.In the source it says "If the predecessor is an indirect goto, we can't split the edge. <http://llvm.org/docs/doxygen/html/JumpThreading_8cpp_source.html#l00914>" Why would that be the case? -- Carlo Alberto Ferraris <cafxx at strayorange.com <mailto:cafxx at strayorange.com>> website/blog <http://cafxx.strayorange.com> - +39 333 7643 235 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110707/ccae877a/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: cafxx.vcf Type: text/x-vcard Size: 233 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110707/ccae877a/attachment.vcf>
Carlo Alberto Ferraris
2011-Jul-18 07:11 UTC
[LLVMdev] Missed optimization with indirectbr terminator
Il 07/07/2011 11:05, Carlo Alberto Ferraris ha scritto:> Is this a known missed optimization?Filed bug 10377 <http://llvm.org/bugs/show_bug.cgi?id=10377> w/testcase. -- Carlo Alberto Ferraris <cafxx at strayorange.com <mailto:cafxx at strayorange.com>> website/blog <http://cafxx.strayorange.com> - +39 333 7643 235 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110718/f53b6580/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: cafxx.vcf Type: text/x-vcard Size: 233 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110718/f53b6580/attachment.vcf>
Apparently Analagous Threads
- [LLVMdev] Missed optimization with indirectbr terminator
- [LLVMdev] Missed optimization with indirectbr terminator
- [LLVMdev] Missed optimization with indirectbr terminator
- [LLVMdev] Missed optimization with indirectbr terminator
- [LLVMdev] Missed optimization with indirectbr terminator