Hi! Whoops, I forgot to reply to this...
On Wed, May 05, 2021 at 06:25:49PM +0000, Koning, Paul wrote: > > void g(void); > > void h(void); > > void i(void); > > void f(long a, long b) > > { > > if (a < b) > > g(); > > if (a == b) > > h(); > > if (a > b) > > i(); > > } > > FWIW, that also works on pdp11, so it seems the general mechanism is in place > and working. Well, with one oddity, an unnecessary third conditional branch: > > _f: > mov 02(sp),r1 > mov 04(sp),r0 > cmp r1,r0 > blt L_7 > beq L_4 > bgt L_5 > rts pc > L_5: > jsr pc,_i > rts pc > L_4: > jsr pc,_h > rts pc > L_7: > jsr pc,_g > rts pc We have that on PowerPC as well (-m32 because it is shorter code with fewer distractions): f: cmpw 0,3,4 blt 0,.L9 beq 0,.L3 blelr 0 b i .p2align 4,,15 .L3: b h .p2align 4,,15 .L9: b g The "blelr" (branch to LR if less than or equal) can never be taken. This is there in the Gimple already: === void f (long int a, long int b) { ;; basic block 2, loop depth 0 ;; pred: ENTRY if (a_4(D) < b_5(D)) goto <bb 3>; [33.00%] else goto <bb 4>; [67.00%] ;; succ: 3 ;; 4 ;; basic block 3, loop depth 0 ;; pred: 2 g (); [tail call] goto <bb 8>; [100.00%] ;; succ: 8 ;; basic block 4, loop depth 0 ;; pred: 2 if (a_4(D) == b_5(D)) goto <bb 6>; [30.21%] else goto <bb 5>; [69.79%] ;; succ: 6 ;; 5 ;; basic block 5, loop depth 0 ;; pred: 4 if (a_4(D) > b_5(D)) goto <bb 7>; [70.57%] else goto <bb 8>; [29.43%] ;; succ: 7 ;; 8 ;; basic block 6, loop depth 0 ;; pred: 4 h (); [tail call] goto <bb 8>; [100.00%] ;; succ: 8 ;; basic block 7, loop depth 0 ;; pred: 5 i (); [tail call] ;; succ: 8 ;; basic block 8, loop depth 0 ;; pred: 5 ;; 7 ;; 6 ;; 3 return; ;; succ: EXIT } === So, it also exists in the RTL -- and it isn't optimised away later. That would be quite hard to do in fact, and if it is handled in Gimple all will be fine, and it should be much easier to do in Gimple. Can you open a PR please? Segher