if (loongarch_int_order_operand_ok_p (*code, *cmp1))
return true;
- if (CONST_INT_P (*cmp1))
switch (*code)
{
case LE:
- plus_one = trunc_int_for_mode (UINTVAL (*cmp1) + 1, mode);
- if (INTVAL (*cmp1) < plus_one)
+ if (CONST_INT_P (*cmp1))
{
- *code = LT;
- *cmp1 = force_reg (mode, GEN_INT (plus_one));
- return true;
+ plus_one = trunc_int_for_mode (UINTVAL (*cmp1) + 1, mode);
+ if (INTVAL (*cmp1) < plus_one)
+ {
+ *code = LT;
+ *cmp1 = force_reg (mode, GEN_INT (plus_one));
+ return true;
+ }
}
break;
case LEU:
- plus_one = trunc_int_for_mode (UINTVAL (*cmp1) + 1, mode);
- if (plus_one != 0)
+ if (CONST_INT_P (*cmp1))
{
- *code = LTU;
- *cmp1 = force_reg (mode, GEN_INT (plus_one));
- return true;
+ plus_one = trunc_int_for_mode (UINTVAL (*cmp1) + 1, mode);
+ if (plus_one != 0)
+ {
+ *code = LTU;
+ *cmp1 = force_reg (mode, GEN_INT (plus_one));
+ return true;
+ }
}
break;
+ case GT:
+ case GTU:
+ case LT:
+ case LTU:
+ *cmp1 = force_reg (mode, *cmp1);
+ break;
+
default:
break;
}
else
{
*op0 = gen_rtx_SIGN_EXTEND (word_mode, *op0);
- if (*op1 != const0_rtx)
+ /* Regardless of whether *op1 is any immediate number, it is not
+ loaded into the register, in order to facilitate the generation
+ of slt{u}i. */
+ if (!CONST_INT_P (*op1))
*op1 = gen_rtx_SIGN_EXTEND (word_mode, *op1);
}
}
;; These code iterators allow the signed and unsigned scc operations to use
;; the same template.
+(define_code_iterator any_ge [ge geu])
(define_code_iterator any_gt [gt gtu])
(define_code_iterator any_lt [lt ltu])
(define_code_iterator any_le [le leu])
[(set_attr "type" "slt")
(set_attr "mode" "<X:MODE>")])
+(define_insn "*sge<u>_<X:mode><GPR:mode>"
+ [(set (match_operand:GPR 0 "register_operand" "=r")
+ (any_ge:GPR (match_operand:X 1 "register_operand" " r")
+ (const_int 1)))]
+ ""
+ "slti<u>\t%0,zero,%1"
+ [(set_attr "type" "slt")
+ (set_attr "mode" "<X:MODE>")])
+
(define_insn "*sgt<u>_<X:mode><GPR:mode>"
[(set (match_operand:GPR 0 "register_operand" "=r")
(any_gt:GPR (match_operand:X 1 "register_operand" "r")
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-mabi=lp64d -O2" } */
+/* { dg-final { scan-assembler "sltui" } } */
+
+union any {
+ int any_i32;
+};
+
+extern char *opname;
+extern void test1 (int, char *);
+extern int iterms;
+
+void
+test (union any cv)
+{
+ int i, on;
+ int ix = cv.any_i32;
+ for (i = 1; i < iterms; i++)
+ {
+ on = (ix == 0 || ix == 1) ? 0 : 1;
+ if (*opname == '!')
+ {
+ on = !on;
+ ++opname;
+ }
+ test1 (on, opname);
+ }
+}
+