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

--- Comment #1 from Hongtao Liu <liuhongt at gcc dot gnu.org> ---
mulx almost costs same as mul on all platforms w/o clobber flags, so with BMI2,
let's generate xmulx for umuldi3_highpart?

11937;; 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}"
11948  [(set_attr "type" "imulx")
11949   (set_attr "prefix" "vex")
11950   (set_attr "mode" "<MODE>")])
11951
11952;; Highpart multiplication patterns
11953(define_insn "<s>mul<mode>3_highpart"
11954  [(set (match_operand:DWIH 0 "register_operand" "=d")
11955        (any_mul_highpart:DWIH
11956          (match_operand:DWIH 1 "register_operand" "%a")
11957          (match_operand:DWIH 2 "nonimmediate_operand" "rm")))
11958   (clobber (match_scratch:DWIH 3 "=1"))
11959   (clobber (reg:CC FLAGS_REG))]
11960  ""
11961  "<sgnprefix>mul{<imodesuffix>}\t%2"
11962  [(set_attr "type" "imul")
11963   (set_attr "length_immediate" "0")

Reply via email to