Bug 85096 - [6/7/8 Regression] Unnecessary(?) MOV instructions for int128 addition
Summary: [6/7/8 Regression] Unnecessary(?) MOV instructions for int128 addition
Status: RESOLVED DUPLICATE of bug 79185
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 8.0
: P2 normal
Target Milestone: 6.5
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization, ra
Depends on:
Blocks:
 
Reported: 2018-03-27 15:04 UTC by Jonathan Wakely
Modified: 2018-04-06 07:06 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.8.5
Known to fail: 4.9.4, 5.5.0, 6.3.0, 7.3.0, 8.0.1
Last reconfirmed: 2018-03-27 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2018-03-27 15:04:03 UTC
__uint128_t add128(__uint128_t a, __uint128_t b) {
  return a + b;
}

GCC with -O3 produces:

        mov     r9, rdi   # a, a
        mov     r10, rsi  # a, a
        add     r9, rdx   # a, b
        adc     r10, rcx  # a, b
        mov     rax, r9   # tmp93, a
        mov     rdx, r10  #, a
        ret

GCC 4.8.5 produced:

        mov     rax, rdx  # D.1732, b
        mov     rdx, rcx  # D.1732, b
        add     rax, rdi  # D.1732, a
        adc     rdx, rsi  # D.1732, a
        ret

Clang produces:

        add     rdi, rdx
        adc     rsi, rcx
        mov     rax, rdi
        mov     rdx, rsi
        ret

and ICC:

  add rdi, rdx #3.14
  mov rax, rdi #3.14
  adc rsi, rcx #3.14
  mov rdx, rsi #3.14
  ret #3.14


I don't know which component this should be, but Jakub suggested to CC Vlad and Uros, so maybe one of you can re-assign it to the right component.
Comment 1 Jonathan Wakely 2018-03-27 15:17:09 UTC
This regressed with r204212

commit 284f069678f0b28c57e62b5da9b6dfed77d4d700
Author: vmakarov <vmakarov@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Wed Oct 30 14:27:25 2013 +0000

    2013-10-30  Vladimir Makarov  <vmakarov@redhat.com>
    
            * regmove.c: Remove.
            * tree-pass.h (make_pass_regmove): Remove.
            * timevar.def (TV_REGMOVE): Remove.
            * passes.def (pass_regmove): Remove.
            * opts.c (default_options_table): Remove entry for regmove.
            * doc/passes.texi: Remove regmove pass description.
            * doc/invoke.texi (-foptimize-register-move, -fregmove): Remove
            options.
            (-fdump-rtl-regmove): Ditto.
            * common.opt (foptimize-register-move, fregmove): Ignore.
            * Makefile.in (OBJS): Remove regmove.o.
            * regmove.c: Remove.
            * ira-int.h (struct ira_allocno_pref, ira_pref_t): New structure
            and type.
            (struct ira_allocno) New member allocno_prefs.
            (ALLOCNO_PREFS): New macro.
            (ira_prefs, ira_prefs_num): New external vars.
            (ira_setup_alts, ira_get_dup_out_num, ira_debug_pref): New
            prototypes.
            (ira_debug_prefs, ira_debug_allocno_prefs, ira_create_pref):
            Ditto.
            (ira_add_allocno_pref, ira_remove_pref, ira_remove_allocno_prefs):
            Ditto.
            (ira_add_allocno_copy_to_list): Remove prototype.
            (ira_swap_allocno_copy_ends_if_necessary): Ditto.
            (ira_pref_iterator): New type.
            (ira_pref_iter_init, ira_pref_iter_cond): New functions.
            (FOR_EACH_PREF): New macro.
            * ira.c (commutative_constraint_p): Move from ira-conflicts.c.
            (ira_get_dup_out_num): Ditto. Rename from get_dup_num.  Modify the
            code.
            (ira_setup_alts): New function.
            (decrease_live_ranges_number): New function.
            (ira): Call the above function.
            * ira-build.c (ira_prefs, ira_prefs_num): New global vars.
            (ira_create_allocno): Initialize allocno prefs.
            (pref_pool, pref_vec): New static vars.
            (initiate_prefs, find_allocno_pref, ira_create_pref): New
            functions.
            (add_allocno_pref_to_list, ira_add_allocno_pref, print_pref): Ditto.
            (ira_debug_pref, print_prefs, ira_debug_prefs): Ditto.
            (print_allocno_prefs, ira_debug_allocno_prefs, finish_pref): Ditto.
            (ira_remove_pref, ira_remove_allocno_prefs, finish_prefs): Ditto.
            (ira_add_allocno_copy_to_list): Make static.  Rename to
            add_allocno_copy_to_list.
            (ira_swap_allocno_copy_ends_if_necessary): Make static.  Rename to
            swap_allocno_copy_ends_if_necessary.
            (remove_unnecessary_allocnos, remove_low_level_allocnos): Call
            ira_remove_allocno_prefs.
            (ira_flattening): Ditto.
            (ira_build): Call initiate_prefs, print_prefs.
            (ira_destroy): Call finish_prefs.
            * ira-color.c (struct update_cost_record): New.
            (struct allocno_color_data): Add new member update_cost_records.
            (update_cost_record_pool): New static var.
            (init_update_cost_records, get_update_cost_record): New functions.
            (free_update_cost_record_list, finish_update_cost_records): Ditto.
            (struct update_cost_queue_elem): Add member from.
            (initiate_cost_update): Call init_update_cost_records.
            (finish_cost_update): Call finish_update_cost_records.
            (queue_update_cost, get_next_update_cost): Add new param from.
            (Update_allocno_cost, update_costs_from_allocno): New functions.
            (update_costs_from_prefs): Ditto.
            (update_copy_costs): Rename to update_costs_from_copies.
            (restore_costs_from_copies): New function.
            (update_conflict_hard_regno_costs): Don't go back.
            (assign_hard_reg): Call restore_costs_from_copies.  Add printing
            more debug info.
            (pop_allocnos): Add priniting more debug info.
            (color_allocnos): Remove prefs for conflicting hard regs.
            Call update_costs_from_prefs.
            * ira-conflicts.c (commutative_constraint_p): Move to ira.c
            (get_dup_num): Rename, modify, and move to ira.c
            (process_regs_for_copy): Add prefs.
            (add_insn_allocno_copies): Put src as first arg of
            process_regs_for_copy.  Remove dead code.  Call ira_setup_alts.
            * ira-costs.c (record_reg_classes): Modify and move code into
            record_operands_costs.
            (find_costs_and_classes): Create prefs for the hard reg of small
            reg class.
            (process_bb_node_for_hard_reg_moves): Add prefs.
    
    2013-10-30  Vladimir Makarov  <vmakarov@redhat.com>
    
            * gcc.target/i386/fma_double_3.c: Use pattern for
            scan-assembler-times instead of just one insn name.
            * gcc.target/i386/fma_double_5.c: Ditto.
            * gcc.target/i386/fma_float_3.c: Ditto.
            * gcc.target/i386/fma_float_5.c: Ditto.
            * gcc.target/i386/l_fma_double_1.c: Ditto.
            * gcc.target/i386/l_fma_double_2.c: Ditto.
            * gcc.target/i386/l_fma_double_3.c: Ditto.
            * gcc.target/i386/l_fma_double_4.c: Ditto.
            * gcc.target/i386/l_fma_double_5.c: Ditto.
            * gcc.target/i386/l_fma_double_6.c: Ditto.
            * gcc.target/i386/l_fma_float_1.c: Ditto.
            * gcc.target/i386/l_fma_float_2.c: Ditto.
            * gcc.target/i386/l_fma_float_3.c: Ditto.
            * gcc.target/i386/l_fma_float_4.c: Ditto.
            * gcc.target/i386/l_fma_float_5.c: Ditto.
            * gcc.target/i386/l_fma_float_6.c: Ditto.
    
    
    
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204212 138bc75d-0d04-0410-961f-82ee72b054a4
Comment 2 Jakub Jelinek 2018-03-27 15:22:15 UTC
Maybe related to PR84757.
Comment 3 Jakub Jelinek 2018-04-06 07:06:57 UTC
Actually, we have a dup for this already.

*** This bug has been marked as a duplicate of bug 79185 ***