Bug 115369 - ifcvt failed to condition elimination for __builtin_mul_overflow
Summary: ifcvt failed to condition elimination for __builtin_mul_overflow
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 15.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2024-06-06 07:49 UTC by Hongtao Liu
Modified: 2024-06-07 00:52 UTC (History)
3 users (show)

See Also:
Host:
Target: x86_64-*-* i?86-*-* aarch64-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2024-06-07 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hongtao Liu 2024-06-06 07:49:49 UTC
int
foo (unsigned a, unsigned b, unsigned d, unsigned e, int* p)
{
    unsigned int r;
    int c = __builtin_mul_overflow (a, b, &r);
    d += c;
    return c ? d : e;
}


(jump_insn 14 13 47 2 (set (pc)
        (if_then_else (eq (reg:CCO 17 flags)
                (const_int 0 [0]))
            (label_ref 17)
            (pc))) "/app/example.c":5:13 1212 {*jcc}
     (expr_list:REG_DEAD (reg:CCO 17 flags)
        (int_list:REG_BR_PROB 536868 (nil)))
 -> 17)
(note 47 14 17 3 [bb 3] NOTE_INSN_BASIC_BLOCK)
      ; pc falls through to BB 5
(code_label 17 47 40 4 3 (nil) [1 uses])
(note 40 17 29 4 [bb 4] NOTE_INSN_BASIC_BLOCK)
(insn 29 40 30 4 (parallel [
            (set (reg/v:SI 105 [ e ])
                (plus:SI (reg/v:SI 104 [ d ])
                    (const_int 1 [0x1])))
            (clobber (reg:CC 17 flags))
        ]) "/app/example.c":6:7 272 {*addsi_1}
     (expr_list:REG_DEAD (reg/v:SI 104 [ d ])
        (expr_list:REG_UNUSED (reg:CC 17 flags)
            (nil))))
(code_label 30 29 31 5 4 (nil) [0 uses])
(note 31 30 36 5 [bb 5] NOTE_INSN_BASIC_BLOCK)
(insn 36 31 37 5 (set (reg/i:SI 0 ax)
        (reg/v:SI 105 [ e ])) "/app/example.c":8:1 85 {*movsi_internal}
     (expr_list:REG_DEAD (reg/v:SI 105 [ e ])
        (nil)))
(insn 37 36 0 5 (use (reg/i:SI 0 ax)) "/app/example.c":8:1 -1
     (nil))

The ce2 dump looks quite simple, not sure why it failed.
Comment 1 Andrew Pinski 2024-06-07 00:52:20 UTC
Happens on aarch64 also.