(match_operand:GPI 1 "register_operand" "r")
(minus:QI (match_operand 2 "const_int_operand" "n")
(match_operand:QI 3 "register_operand" "r"))))]
- "INTVAL (operands[2]) == GET_MODE_BITSIZE (<MODE>mode)"
+ "INTVAL (operands[2]) == GET_MODE_BITSIZE (<MODE>mode)
+ || INTVAL (operands[2]) == GET_MODE_BITSIZE (<MODE>mode) - 1"
"#"
"&& true"
[(const_int 0)]
rtx tmp = (can_create_pseudo_p () ? gen_reg_rtx (SImode)
: gen_lowpart (SImode, operands[0]));
- emit_insn (gen_negsi2 (tmp, subreg_tmp));
+ if (INTVAL (operands[2]) == GET_MODE_BITSIZE (<MODE>mode))
+ emit_insn (gen_negsi2 (tmp, subreg_tmp));
+ else
+ emit_insn (gen_one_cmplsi2 (tmp, subreg_tmp));
rtx and_op = gen_rtx_AND (SImode, tmp,
GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 1));
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-final { check-function-bodies "**" "" "" } } */
+
+#include <stdint.h>
+
+/*
+** f1:
+** mvn w1, w1
+** lsl w0, w0, w1
+** ret
+*/
+
+int f1 (int x, int n)
+{
+ return x << (31 - n);
+}
+
+/*
+** f2:
+** mvn w1, w1
+** asr w0, w0, w1
+** ret
+*/
+
+int f2 (int x, int n)
+{
+ return x >> (31 - n);
+}
+
+/*
+** f3:
+** mvn w1, w1
+** lsr x0, x0, x1
+** ret
+*/
+
+unsigned long f3 (unsigned long long x, int n)
+{
+ return x >> (63 - n);
+}
+
+/*
+** f4:
+** mvn w1, w1
+** lsl x0, x0, x1
+** ret
+*/
+
+long f4 (long x, int n)
+{
+ return x << (63 - n);
+}