Skip to content
Snippets Groups Projects
  • Jeff Law's avatar
    98914f9e
    [to-be-committed][RISC-V][V3] DCE analysis for extension elimination · 98914f9e
    Jeff Law authored
    
    The pre-commit testing showed that making ext-dce only active at -O2 and above
    would require minor edits to the tests.  In some cases we had specified -O1 in
    the test or specified no optimization level at all. Those need to be bumped to
    -O2.   In one test we had one set of dg-options overriding another.
    
    The other approach that could have been taken would be to drop the -On
    argument, add an explicit -fext-dce and add dg-skip-if options.  I originally
    thought that was going to be way to go, but the dg-skip-if aspect was going to
    get ugly as things like interaction between unrolling, peeling and -ftracer
    would have to be accounted for and would likely need semi-regular adjustment.
    
    Changes since V2:
      Testsuite changes to deal with pass only being enabled at -O2 or
      higher.
    
    --
    
    Changes since V1:
    
      Check flag_ext_dce before running the new pass.  I'd forgotten that
      I had removed that part of the gate to facilitate more testing.
      Turn flag_ext_dce on at -O2 and above.
      Adjust one of the riscv tests to explicitly avoid vectors
      Adjust a few aarch64 tests
        In tbz_2.c we remove an unnecessary extension which causes us to use
        "x" registers instead of "w" registers.
    
        In the pred_clobber tests we also remove an extension and that
        ultimately causes a reg->reg copy to change locations.
    
    --
    
    This was actually ack'd late in the gcc-14 cycle, but I chose not to integrate
    it given how late we were in the cycle.
    
    The basic idea here is to track liveness of subobjects within a word and if we
    find an extension where the bits set aren't actually used, then we convert the
    extension into a subreg.  The subreg typically simplifies away.
    
    I've seen this help a few routines in coremark, fix one bug in the testsuite
    (pr111384) and fix a couple internally reported bugs in Ventana.
    
    The original idea and code were from Joern; Jivan and I hacked it into usable
    shape.  I've had this in my tester for ~8 months, so it's been through more
    build/test cycles than I care to contemplate and nearly every architecture we
    support.
    
    But just in case, I'm going to wait for it to spin through the pre-commit CI
    tester.  I'll find my old ChangeLog before committing.
    
    gcc/
    	* Makefile.in (OBJS): Add ext-dce.o
    	* common.opt (ext-dce): Document new option.
    	* df-scan.cc (df_get_ext_block_use_set): Delete prototype and
    	make extern.
    	* df.h (df_get_exit_block_use_set): Prototype.
    	* ext-dce.cc: New file/pass.
    	* opts.cc (default_options_table): Handle ext-dce at -O2 or higher.
    	* passes.def: Add ext-dce before combine.
    	* tree-pass.h (make_pass_ext_dce): Prototype.
    
    gcc/testsuite
    	* gcc.target/aarch64/sve/pred_clobber_1.c: Update expected output.
    	* gcc.target/aarch64/sve/pred_clobber_2.c: Likewise.
    	* gcc.target/aarch64/sve/pred_clobber_3.c: Likewise.
    	* gcc.target/aarch64/tbz_2.c: Likewise.
    	* gcc.target/riscv/core_bench_list.c: New test.
    	* gcc.target/riscv/core_init_matrix.c: New test.
    	* gcc.target/riscv/core_list_init.c: New test.
    	* gcc.target/riscv/matrix_add_const.c: New test.
    	* gcc.target/riscv/mem-extend.c: New test.
    	* gcc.target/riscv/pr111384.c: New test.
    
    Co-authored-by: default avatarJivan Hakobyan <jivanhakobyan9@gmail.com>
    Co-authored-by: default avatarJoern Rennecke <joern.rennecke@embecosm.com>
    98914f9e
    History
    [to-be-committed][RISC-V][V3] DCE analysis for extension elimination
    Jeff Law authored
    
    The pre-commit testing showed that making ext-dce only active at -O2 and above
    would require minor edits to the tests.  In some cases we had specified -O1 in
    the test or specified no optimization level at all. Those need to be bumped to
    -O2.   In one test we had one set of dg-options overriding another.
    
    The other approach that could have been taken would be to drop the -On
    argument, add an explicit -fext-dce and add dg-skip-if options.  I originally
    thought that was going to be way to go, but the dg-skip-if aspect was going to
    get ugly as things like interaction between unrolling, peeling and -ftracer
    would have to be accounted for and would likely need semi-regular adjustment.
    
    Changes since V2:
      Testsuite changes to deal with pass only being enabled at -O2 or
      higher.
    
    --
    
    Changes since V1:
    
      Check flag_ext_dce before running the new pass.  I'd forgotten that
      I had removed that part of the gate to facilitate more testing.
      Turn flag_ext_dce on at -O2 and above.
      Adjust one of the riscv tests to explicitly avoid vectors
      Adjust a few aarch64 tests
        In tbz_2.c we remove an unnecessary extension which causes us to use
        "x" registers instead of "w" registers.
    
        In the pred_clobber tests we also remove an extension and that
        ultimately causes a reg->reg copy to change locations.
    
    --
    
    This was actually ack'd late in the gcc-14 cycle, but I chose not to integrate
    it given how late we were in the cycle.
    
    The basic idea here is to track liveness of subobjects within a word and if we
    find an extension where the bits set aren't actually used, then we convert the
    extension into a subreg.  The subreg typically simplifies away.
    
    I've seen this help a few routines in coremark, fix one bug in the testsuite
    (pr111384) and fix a couple internally reported bugs in Ventana.
    
    The original idea and code were from Joern; Jivan and I hacked it into usable
    shape.  I've had this in my tester for ~8 months, so it's been through more
    build/test cycles than I care to contemplate and nearly every architecture we
    support.
    
    But just in case, I'm going to wait for it to spin through the pre-commit CI
    tester.  I'll find my old ChangeLog before committing.
    
    gcc/
    	* Makefile.in (OBJS): Add ext-dce.o
    	* common.opt (ext-dce): Document new option.
    	* df-scan.cc (df_get_ext_block_use_set): Delete prototype and
    	make extern.
    	* df.h (df_get_exit_block_use_set): Prototype.
    	* ext-dce.cc: New file/pass.
    	* opts.cc (default_options_table): Handle ext-dce at -O2 or higher.
    	* passes.def: Add ext-dce before combine.
    	* tree-pass.h (make_pass_ext_dce): Prototype.
    
    gcc/testsuite
    	* gcc.target/aarch64/sve/pred_clobber_1.c: Update expected output.
    	* gcc.target/aarch64/sve/pred_clobber_2.c: Likewise.
    	* gcc.target/aarch64/sve/pred_clobber_3.c: Likewise.
    	* gcc.target/aarch64/tbz_2.c: Likewise.
    	* gcc.target/riscv/core_bench_list.c: New test.
    	* gcc.target/riscv/core_init_matrix.c: New test.
    	* gcc.target/riscv/core_list_init.c: New test.
    	* gcc.target/riscv/matrix_add_const.c: New test.
    	* gcc.target/riscv/mem-extend.c: New test.
    	* gcc.target/riscv/pr111384.c: New test.
    
    Co-authored-by: default avatarJivan Hakobyan <jivanhakobyan9@gmail.com>
    Co-authored-by: default avatarJoern Rennecke <joern.rennecke@embecosm.com>