@@ -159,6 +159,8 @@ (define_c_enum "unspec"
UNSPEC_XXSPLTIW_CONST
UNSPEC_FMAX
UNSPEC_FMIN
+ UNSPEC_MFCR
+ UNSPEC_ROTATE_CR
])
;;
@@ -12744,26 +12746,51 @@ (define_insn_and_split "*cmp<IBM128:mode>_internal2"
}
})
-;; Now we have the scc insns. We can do some combinations because of the
-;; way the machine works.
-;;
-;; Note that this is probably faster if we can put an insn between the
-;; mfcr and rlinm, but this is tricky. Let's leave it for now. In most
-;; cases the insns below which don't use an intermediate CR field will
-;; be used instead.
-(define_insn "set<mode>_cc"
+
+(define_insn "*move_from_cr"
[(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
- (match_operator:GPR 1 "scc_comparison_operator"
- [(match_operand 2 "cc_reg_operand" "y")
- (const_int 0)]))]
+ (unspec:GPR [(match_operand 1 "cc_reg_operand" "y")]
+ UNSPEC_MFCR))]
""
- "mfcr %0%Q2\;rlwinm %0,%0,%J1,1"
+ "mfcr %0%Q1"
[(set (attr "type")
(cond [(match_test "TARGET_MFCRF")
(const_string "mfcrf")
]
- (const_string "mfcr")))
- (set_attr "length" "8")])
+ (const_string "mfcr")))])
+
+;; Split the insn after reload so that other insns can be inserted
+;; between mfcr and rlinm.
+(define_insn_and_split "set<mode>_cc"
+ [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
+ (match_operator:GPR 1 "scc_comparison_operator"
+ [(match_operand 2 "cc_reg_operand" "y")
+ (const_int 0)]))]
+ "!TARGET_POWER10
+ || (GET_MODE (operands[2]) != CCmode
+ && GET_MODE (operands[2]) != CCUNSmode)"
+ "#"
+ "&& reload_completed"
+ [(set (match_dup 0)
+ (unspec:GPR [(match_dup 2)]
+ UNSPEC_MFCR))
+ (set (match_dup 0)
+ (unspec:GPR [(match_dup 0)
+ (match_dup 1)]
+ UNSPEC_ROTATE_CR))]
+ ""
+ [(set_attr "length" "8")])
+
+(define_insn "*rotate_cr"
+ [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
+ (unspec:GPR [(match_operand:GPR 3 "gpc_reg_operand" "r")
+ (match_operator:GPR 1 "scc_comparison_operator"
+ [(match_operand 2 "cc_reg_operand" "y")
+ (const_int 0)])]
+ UNSPEC_ROTATE_CR))]
+ ""
+ "rlwinm %0,%3,%J1,1"
+)
(define_insn_and_split "*set<GPR:mode><CCANY:mode>_rev"
[(set (match_operand:GPR 0 "gpc_reg_operand" "=r")