[(set_attr "type" "f_cvtf2i")]
)
-;; fma - no throw
+;; fma - expand fma into patterns with the accumulator operand first since
+;; reusing the accumulator results in better register allocation.
+;; The register allocator considers copy preferences in operand order,
+;; so this prefers fmadd s0, s1, s2, s0 over fmadd s1, s1, s2, s0.
+
+(define_expand "fma<mode>4"
+ [(set (match_operand:GPF_F16 0 "register_operand")
+ (fma:GPF_F16 (match_operand:GPF_F16 1 "register_operand")
+ (match_operand:GPF_F16 2 "register_operand")
+ (match_operand:GPF_F16 3 "register_operand")))]
+ "TARGET_FLOAT"
+)
-(define_insn "fma<mode>4"
+(define_insn "*aarch64_fma<mode>4"
[(set (match_operand:GPF_F16 0 "register_operand" "=w")
- (fma:GPF_F16 (match_operand:GPF_F16 1 "register_operand" "w")
- (match_operand:GPF_F16 2 "register_operand" "w")
- (match_operand:GPF_F16 3 "register_operand" "w")))]
+ (fma:GPF_F16 (match_operand:GPF_F16 2 "register_operand" "w")
+ (match_operand:GPF_F16 3 "register_operand" "w")
+ (match_operand:GPF_F16 1 "register_operand" "w")))]
"TARGET_FLOAT"
- "fmadd\\t%<s>0, %<s>1, %<s>2, %<s>3"
+ "fmadd\\t%<s>0, %<s>2, %<s>3, %<s>1"
[(set_attr "type" "fmac<stype>")]
)
-(define_insn "fnma<mode>4"
+(define_expand "fnma<mode>4"
+ [(set (match_operand:GPF_F16 0 "register_operand")
+ (fma:GPF_F16
+ (neg:GPF_F16 (match_operand:GPF_F16 1 "register_operand"))
+ (match_operand:GPF_F16 2 "register_operand")
+ (match_operand:GPF_F16 3 "register_operand")))]
+ "TARGET_FLOAT"
+)
+
+(define_insn "*aarch64_fnma<mode>4"
[(set (match_operand:GPF_F16 0 "register_operand" "=w")
(fma:GPF_F16
- (neg:GPF_F16 (match_operand:GPF_F16 1 "register_operand" "w"))
- (match_operand:GPF_F16 2 "register_operand" "w")
- (match_operand:GPF_F16 3 "register_operand" "w")))]
+ (neg:GPF_F16 (match_operand:GPF_F16 2 "register_operand" "w"))
+ (match_operand:GPF_F16 3 "register_operand" "w")
+ (match_operand:GPF_F16 1 "register_operand" "w")))]
"TARGET_FLOAT"
- "fmsub\\t%<s>0, %<s>1, %<s>2, %<s>3"
+ "fmsub\\t%<s>0, %<s>2, %<s>3, %<s>1"
[(set_attr "type" "fmac<stype>")]
)
-(define_insn "fms<mode>4"
+
+(define_expand "fms<mode>4"
+ [(set (match_operand:GPF 0 "register_operand")
+ (fma:GPF (match_operand:GPF 1 "register_operand")
+ (match_operand:GPF 2 "register_operand")
+ (neg:GPF (match_operand:GPF 3 "register_operand"))))]
+ "TARGET_FLOAT"
+)
+
+(define_insn "*aarch64_fms<mode>4"
[(set (match_operand:GPF 0 "register_operand" "=w")
- (fma:GPF (match_operand:GPF 1 "register_operand" "w")
- (match_operand:GPF 2 "register_operand" "w")
- (neg:GPF (match_operand:GPF 3 "register_operand" "w"))))]
+ (fma:GPF (match_operand:GPF 2 "register_operand" "w")
+ (match_operand:GPF 3 "register_operand" "w")
+ (neg:GPF (match_operand:GPF 1 "register_operand" "w"))))]
"TARGET_FLOAT"
- "fnmsub\\t%<s>0, %<s>1, %<s>2, %<s>3"
+ "fnmsub\\t%<s>0, %<s>2, %<s>3, %<s>1"
[(set_attr "type" "fmac<s>")]
)
-(define_insn "fnms<mode>4"
+(define_expand "fnms<mode>4"
+ [(set (match_operand:GPF 0 "register_operand")
+ (fma:GPF (neg:GPF (match_operand:GPF 1 "register_operand"))
+ (match_operand:GPF 2 "register_operand")
+ (neg:GPF (match_operand:GPF 3 "register_operand"))))]
+ "TARGET_FLOAT"
+)
+
+(define_insn "*aarch64_fnms<mode>4"
[(set (match_operand:GPF 0 "register_operand" "=w")
- (fma:GPF (neg:GPF (match_operand:GPF 1 "register_operand" "w"))
- (match_operand:GPF 2 "register_operand" "w")
- (neg:GPF (match_operand:GPF 3 "register_operand" "w"))))]
+ (fma:GPF (neg:GPF (match_operand:GPF 2 "register_operand" "w"))
+ (match_operand:GPF 3 "register_operand" "w")
+ (neg:GPF (match_operand:GPF 1 "register_operand" "w"))))]
"TARGET_FLOAT"
- "fnmadd\\t%<s>0, %<s>1, %<s>2, %<s>3"
+ "fnmadd\\t%<s>0, %<s>2, %<s>3, %<s>1"
[(set_attr "type" "fmac<s>")]
)
;; If signed zeros are ignored, -(a * b + c) = -a * b - c.
-(define_insn "*fnmadd<mode>4"
+(define_insn "*aarch64_fnmadd<mode>4"
[(set (match_operand:GPF 0 "register_operand" "=w")
- (neg:GPF (fma:GPF (match_operand:GPF 1 "register_operand" "w")
- (match_operand:GPF 2 "register_operand" "w")
- (match_operand:GPF 3 "register_operand" "w"))))]
+ (neg:GPF (fma:GPF (match_operand:GPF 2 "register_operand" "w")
+ (match_operand:GPF 3 "register_operand" "w")
+ (match_operand:GPF 1 "register_operand" "w"))))]
"!HONOR_SIGNED_ZEROS (<MODE>mode) && TARGET_FLOAT"
- "fnmadd\\t%<s>0, %<s>1, %<s>2, %<s>3"
+ "fnmadd\\t%<s>0, %<s>2, %<s>3, %<s>1"
[(set_attr "type" "fmac<s>")]
)