;; Peephole optimizations for RISC-V for GNU compiler.
-;; Copyright (C) 2011-2023 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2024 Free Software Foundation, Inc.
;; Contributed by Andrew Waterman (andrew@sifive.com).
;; This file is part of GCC.
operands[5] = GEN_INT (INTVAL (operands[2]) - INTVAL (operands[5]));
})
-;; XTheadMemPair: merge two SI or DI loads
+;; ZCMP
(define_peephole2
- [(set (match_operand:GPR 0 "register_operand" "")
- (match_operand:GPR 1 "memory_operand" ""))
- (set (match_operand:GPR 2 "register_operand" "")
- (match_operand:GPR 3 "memory_operand" ""))]
- "TARGET_XTHEADMEMPAIR
- && th_mempair_operands_p (operands, true, <GPR:MODE>mode)"
- [(parallel [(set (match_dup 0) (match_dup 1))
- (set (match_dup 2) (match_dup 3))])]
-{
- th_mempair_order_operands (operands, true, <GPR:MODE>mode);
-})
-
-;; XTheadMemPair: merge two SI or DI stores
-(define_peephole2
- [(set (match_operand:GPR 0 "memory_operand" "")
- (match_operand:GPR 1 "register_operand" ""))
- (set (match_operand:GPR 2 "memory_operand" "")
- (match_operand:GPR 3 "register_operand" ""))]
- "TARGET_XTHEADMEMPAIR
- && th_mempair_operands_p (operands, false, <GPR:MODE>mode)"
- [(parallel [(set (match_dup 0) (match_dup 1))
- (set (match_dup 2) (match_dup 3))])]
-{
- th_mempair_order_operands (operands, false, <GPR:MODE>mode);
-})
+ [(set (match_operand:X 0 "a0a1_reg_operand")
+ (match_operand:X 1 "zcmp_mv_sreg_operand"))
+ (set (match_operand:X 2 "a0a1_reg_operand")
+ (match_operand:X 3 "zcmp_mv_sreg_operand"))]
+ "TARGET_ZCMP
+ && (REGNO (operands[2]) != REGNO (operands[0]))"
+ [(parallel [(set (match_dup 0)
+ (match_dup 1))
+ (set (match_dup 2)
+ (match_dup 3))])]
+)
-;; XTheadMemPair: merge two SI loads with sign-extension
(define_peephole2
- [(set (match_operand:DI 0 "register_operand" "")
- (sign_extend:DI (match_operand:SI 1 "memory_operand" "")))
- (set (match_operand:DI 2 "register_operand" "")
- (sign_extend:DI (match_operand:SI 3 "memory_operand" "")))]
- "TARGET_XTHEADMEMPAIR && TARGET_64BIT
- && th_mempair_operands_p (operands, true, SImode)"
- [(parallel [(set (match_dup 0) (sign_extend:DI (match_dup 1)))
- (set (match_dup 2) (sign_extend:DI (match_dup 3)))])]
-{
- th_mempair_order_operands (operands, true, SImode);
-})
-
-;; XTheadMemPair: merge two SI loads with zero-extension
-(define_peephole2
- [(set (match_operand:DI 0 "register_operand" "")
- (zero_extend:DI (match_operand:SI 1 "memory_operand" "")))
- (set (match_operand:DI 2 "register_operand" "")
- (zero_extend:DI (match_operand:SI 3 "memory_operand" "")))]
- "TARGET_XTHEADMEMPAIR && TARGET_64BIT
- && th_mempair_operands_p (operands, true, SImode)"
- [(parallel [(set (match_dup 0) (zero_extend:DI (match_dup 1)))
- (set (match_dup 2) (zero_extend:DI (match_dup 3)))])]
-{
- th_mempair_order_operands (operands, true, SImode);
-})
+ [(set (match_operand:X 0 "zcmp_mv_sreg_operand")
+ (match_operand:X 1 "a0a1_reg_operand"))
+ (set (match_operand:X 2 "zcmp_mv_sreg_operand")
+ (match_operand:X 3 "a0a1_reg_operand"))]
+ "TARGET_ZCMP
+ && (REGNO (operands[0]) != REGNO (operands[2]))
+ && (REGNO (operands[1]) != REGNO (operands[3]))"
+ [(parallel [(set (match_dup 0)
+ (match_dup 1))
+ (set (match_dup 2)
+ (match_dup 3))])]
+)