<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hi, </div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""></blockquote>We found that early if-conversion pass may introduce some redundant select node. Please see the example below, I use llvm IR here just to make it a little easier to read although early if-conversion is dealing machine instructions. When we if-convert a diamond below, If the tail basic block(while.body) has extra predecessors(while.body.lr.ph), we need to insert select in the head basic block(while.cond) and rewrite the PHI in the tail basic block(while.body). However, if this select node is actually selecting same value, that is redundant. In our case, it is the %j.012 with incoming value of %inc from both %if.then and %if.else. And since early if conversation is pretty late in codegen so the latter passes won’t be able to remove this redundancy. This patch is to remove this redundancy. Bzip2 decompression will benefit from this patch. <div class=""><div class=""><br class=""></div><div class=""><div class="">while.cond: ; Head BB</div><div class=""> ...</div><div class=""> br i1 %cmp2, label %if.then, label %if.else</div><div class=""><br class=""></div><div class="">if.then: ;TBB</div><div class=""> %inc2 = add nsw i32 %i.011, 1</div><div class=""> br label %while.body</div><div class=""><br class=""></div><div class="">if.else: ;FBB</div><div class=""> %dec = add nsw i32 %i.011, -1</div><div class=""> br label %while.body</div><div class=""><br class=""></div></div><div class=""><div class="">while.body: ;Tail BB</div><div class=""> %j.012 = phi i32 [ %sub, %while.body.lr.ph ], [ %inc, %if.then ], [ %inc, %if.else ] ;we dont need a select of %inc and %inc from the TBB/FBB in Head BB</div><div class=""> %i.011 = phi i32 [ %a, %while.body.lr.ph ], [ %inc2, %if.then ], [ %dec, %if.else ] ;we DO need a select of %inc2 and %dec from the TBB/FBB in Head BB</div><div class=""> ...</div><div class=""> br i1 %cmp1, label %while.end, label %while.cond</div></div><div class=""><br class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""></blockquote><br class=""></div></div></body></html>