@@ -1161,6 +1161,54 @@
[(set_attr "type" "mov_imm")]
)
+;; This is for the combiner to use to encourage creation of
+;; bitfield insertions using movk.
+;;
+;; We rewrite back into a movk bitfield insertion to make sched
+;; fusion happy the first chance we get where the appropriate
+;; operands match. After LRA they should always match.
+(define_insn_and_split ""
+ [(set (match_operand:GPI 0 "register_operand" "=r")
+ (ior:GPI (and:GPI (match_operand:GPI 1 "register_operand" "0")
+ (match_operand:GPI 2 "const_int_operand" "n"))
+ (match_operand:GPI 3 "const_int_operand" "n")))]
+ "((UINTVAL (operands[2]) == 0xffffffffffff0000
+ || UINTVAL (operands[2]) == 0xffffffff0000ffff
+ || UINTVAL (operands[2]) == 0xffff0000ffffffff
+ || UINTVAL (operands[2]) == 0x0000ffffffffffff)
+ && (UINTVAL (operands[2]) & UINTVAL (operands[3])) == 0)"
+ "#"
+ "&& rtx_equal_p (operands[0], operands[1])"
+ [(set (zero_extract:<MODE> (match_dup 0)
+ (const_int 16)
+ (match_dup 2))
+ (match_dup 3))]
+ "{
+ if (UINTVAL (operands[2]) == 0xffffffffffff0000)
+ {
+ operands[2] = GEN_INT (0);
+ operands[3] = GEN_INT (UINTVAL (operands[3]) & 0xffff);
+ }
+ else if (UINTVAL (operands[2]) == 0xffffffff0000ffff)
+ {
+ operands[2] = GEN_INT (16);
+ operands[3] = GEN_INT ((UINTVAL (operands[3]) >> 16) & 0xffff);
+ }
+ else if (UINTVAL (operands[2]) == 0xffff0000ffffffff)
+ {
+ operands[2] = GEN_INT (32);
+ operands[3] = GEN_INT ((UINTVAL (operands[3]) >> 32) & 0xffff);
+ }
+ else if (UINTVAL (operands[2]) == 0x0000ffffffffffff)
+ {
+ operands[2] = GEN_INT (48);
+ operands[3] = GEN_INT ((UINTVAL (operands[3]) >> 48) & 0xffff);
+ }
+ else
+ gcc_unreachable ();
+ }"
+)
+
(define_expand "movti"
[(set (match_operand:TI 0 "nonimmediate_operand" "")
(match_operand:TI 1 "general_operand" ""))]