On Thu, Nov 03, 2016 at 04:29:05PM +0100, Eric Botcazou wrote: > > Is VRP the right pass to do this optimisation or should a later > > pass rather attempt to eliminate the new use of b_5 instead? Uli > > has brought up the idea a mini "sign extend elimination" pass that > > checks if the result of a sign extend could be replaced by the > > original quantity in all places, and if so, eliminate the ssa > > name. > > Did you try to enable -free on s390x? It's a RTL pass.
Just tried it, but it does not seem to make a difference: Trying to eliminate extension: (insn 8 6 10 2 (set (reg:SI 1 %r1 [orig:63 b+-3 ] [63]) (zero_extend:SI (reg/v:QI 2 %r2 [orig:60 b ] [60]))) y.c:9 1258 {*zero_extendqisi2_extimm} (nil)) Elimination opportunities = 1 realized = 0 I guess when in Rtl format, the code is already too convoluted to be cleaned up. Before combine - which should make use of some advanced s390x instruction (risbg) but doesn't - Rtl is this: (insn 2 4 3 2 (set (reg/v:DI 62 [ a+-7 ]) (reg:DI 2 %r2 [ a+-7 ])) y.c:3 1074 {*movdi_64} # (SImode)(a & 63) (insn 6 3 8 2 (parallel [ (set (subreg:SI (reg/v:QI 60 [ b ]) 0) (and:SI (subreg/s/v:SI (reg/v:DI 62 [ a+-7 ]) 4) (const_int 63 [0x3f]))) (clobber (reg:CC 33 %cc)) ]) y.c:7 1526 {*andsi3_zarch} (insn 8 6 9 2 (set (reg:SI 63 [ b+-3 ]) (zero_extend:SI (reg/v:QI 60 [ b ]))) y.c:9 1258 {*zero_extendqisi2_extimm} # Compare quantity in SImode (insn 9 8 10 2 (set (reg:CCU 33 %cc) (compare:CCU (reg:SI 63 [ b+-3 ]) (const_int 9 [0x9]))) y.c:9 1047 {*cmpsi_ccu} (jump_insn 10 9 11 2 (set (pc) (if_then_else (leu (reg:CCU 33 %cc) (const_int 0 [0])) (label_ref:DI 18) (pc))) y.c:9 1706 {*cjump_64} # Extend to DImode (insn 12 11 13 3 (set (reg:DI 64 [ l ]) (zero_extend:DI (reg/v:QI 60 [ b ]))) y.c:8 1257 {*zero_extendqidi2_extimm} # Load DImode function argument for call to bar() (insn 13 12 14 3 (set (reg:DI 2 %r2) (reg:DI 64 [ l ])) y.c:10 1074 {*movdi_64} ... Ciao Dominik ^_^ ^_^ -- Dominik Vogt IBM Germany