https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78200
--- Comment #19 from Venkataramanan <venkataramanan.kumar at amd dot com> --- (In reply to rguent...@suse.de from comment #18) > On Tue, 15 Nov 2016, venkataramanan.kumar at amd dot com wrote: > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78200 > > > > --- Comment #17 from Venkataramanan <venkataramanan.kumar at amd dot com> > > --- > > Looking at the check > > red_cost < 0 && arc->ident == AT_LOWER) > > || (red_cost > 0 && arc->ident == AT_UPPER > > > > The order if-combine created seem to be the best. > > > > if (red_cost_86 < 0) > > goto <bb 17>; > > else > > goto <bb 18>; > > > > <bb 17>: > > if (_23 == 1) > > goto <bb 19>; > > else > > goto <bb 20>; > > > > <bb 18>: > > _340 = _23 == 2; > > _341 = red_cost_86 > 0; > > _338 = _340 & _341; > > if (_338 != 0) > > goto <bb 19>; > > else > > goto <bb 20>; > > > > <bb 19>: > > basket_size.5_30 = basket_size; > > _31 = basket_size.5_30 + 1; > > basket_size = _31; > > _32 = perm[_31]; > > _32->a = arc_47; > > _32->cost = red_cost_86; > > _33 = ABS_EXPR <red_cost_86>; > > _32->abs_cost = _33; > > > > If red_cost < 0 is false then checking for arc->ident == AT_UPPER first. > > This > > is better, since we know red_cost >0 will always be true. > > red_cost can be zero. The "bad" order is best (just slower for some > still unknown reason). Could be the case red_cost is always > zero but arc->ident is not AT_UPPER, checking like this (arc->ident == AT_UPPER && red_cost > 0) is faster. The static predication also says so red_cost > 0 is 88% true. if (red_cost_86 < 0) goto <bb 17>; else goto <bb 18>; ;; succ: 17 [36.0%] (TRUE_VALUE,EXECUTABLE) ;; 18 [64.0%] (FALSE_VALUE,EXECUTABLE) ;; basic block 17, loop depth 2, count 0, freq 684, maybe hot ;; prev block 16, next block 18, flags: (NEW, REACHABLE, VISITED) ;; pred: 16 [36.0%] (TRUE_VALUE,EXECUTABLE) if (_23 == 1) goto <bb 20>; else goto <bb 21>; ;; succ: 20 [34.0%] (TRUE_VALUE,EXECUTABLE) ;; 21 [66.0%] (FALSE_VALUE,EXECUTABLE) ;; basic block 18, loop depth 2, count 0, freq 1217, maybe hot ;; prev block 17, next block 19, flags: (NEW, REACHABLE, VISITED) ;; pred: 16 [64.0%] (FALSE_VALUE,EXECUTABLE) if (red_cost_86 > 0) goto <bb 19>; else goto <bb 21>; ;; succ: 19 [87.7%] (TRUE_VALUE,EXECUTABLE) <== ~88% ;; 21 [12.3%] (FALSE_VALUE,EXECUTABLE) ;; basic block 19, loop depth 2, count 0, freq 1067, maybe hot ;; prev block 18, next block 20, flags: (NEW, REACHABLE, VISITED) ;; pred: 18 [87.7%] (TRUE_VALUE,EXECUTABLE) if (_23 == 2) goto <bb 20>; else goto <bb 21>; ;; succ: 20 [34.0%] (TRUE_VALUE,EXECUTABLE) ;; 21 [66.0%] (FALSE_VALUE,EXECUTABLE)