https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127452

--- Comment #14 from vekumar at gcc dot gnu.org ---
(In reply to Hongtao Liu from comment #13)
> For the scalar part
> 
> typedef unsigned long long u64;
> 
> u64
> mulh (u64 a, u64 b)
> {
>   return ((unsigned __int128) a * b) >> 64;
> }
> 
> gcc -O2 -march=x86-64-v2 -mbmi2
> 
> "mulh":
>         mov     rax, rdi
>         mul     rsi
>         mov     rax, rdx
>         ret
> 
> 
> dump of reload:
> 
> (insn 8 21 15 2 (parallel [
>             (set (reg:DI 1 dx [orig:106 highparttmp_9 ] [106])
>                 (umul_highpart:DI (reg:DI 0 ax [orig:108 a ] [108])
>                     (reg:DI 4 si [orig:109 b ] [109])))
>             (clobber (reg:DI 0 ax [orig:108 a ] [108]))
>             (clobber (reg:CC 17 flags))
>         ]) "/app/example.c":6:38 660 {umuldi3_highpart}
>      (nil))
> 
> 
> 1937;; BMI2 MULX highpart-only pattern.  Uses MULX to get only the high part.
> 11938;; When both output operands are identical, MULX writes the high half
> to that
> 11939;; register, so no scratch register is needed.  This avoids the mov
> from rdx
> 11940;; after mulq when only the high part is needed.
> 11941(define_insn "*bmi2_umul<mode>3_highpart"
> 11942  [(set (match_operand:DWIH 0 "register_operand" "=r")
> 11943        (umul_highpart:DWIH
> 11944          (match_operand:DWIH 1 "register_operand" "d")
> 11945          (match_operand:DWIH 2 "nonimmediate_operand" "rm")))]
> 11946  "TARGET_BMI2"
> 11947  "mulx\t{%2, %0, %0|%0, %0, %2}"
> 
> Why this is not matched.

Created a fresh PR for this https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127900

Reply via email to