aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/config/riscv/riscv.md24
-rw-r--r--gcc/testsuite/gcc.target/riscv/pr118122.c12
2 files changed, 24 insertions, 12 deletions
diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md
index 6c6155c..deb1560 100644
--- a/gcc/config/riscv/riscv.md
+++ b/gcc/config/riscv/riscv.md
@@ -861,19 +861,19 @@
;; Transform (X & C1) + C2 into (X | ~C1) - (-C2 | ~C1)
;; Where C1 is not a LUI operand, but ~C1 is a LUI operand
-(define_insn_and_split "*lui_constraint<ANYI:mode>_and_to_or"
- [(set (match_operand:ANYI 0 "register_operand" "=r")
- (plus:ANYI (and:ANYI (match_operand:ANYI 1 "register_operand" "r")
- (match_operand 2 "const_int_operand"))
- (match_operand 3 "const_int_operand")))
+(define_insn_and_split "*lui_constraint<X:mode>_and_to_or"
+ [(set (match_operand:X 0 "register_operand" "=r")
+ (plus:X (and:X (match_operand:X 1 "register_operand" "r")
+ (match_operand 2 "const_int_operand"))
+ (match_operand 3 "const_int_operand")))
(clobber (match_scratch:X 4 "=&r"))]
- "LUI_OPERAND (~INTVAL (operands[2]))
- && ((INTVAL (operands[2]) & (-INTVAL (operands[3])))
- == (-INTVAL (operands[3])))
- && riscv_const_insns (operands[3], false)
- && (riscv_const_insns
- (GEN_INT (~INTVAL (operands[2]) | -INTVAL (operands[3])), false)
- <= riscv_const_insns (operands[3], false))"
+ "(LUI_OPERAND (~INTVAL (operands[2]))
+ && ((INTVAL (operands[2]) & (-INTVAL (operands[3])))
+ == (-INTVAL (operands[3])))
+ && riscv_const_insns (operands[3], false)
+ && (riscv_const_insns (GEN_INT (~INTVAL (operands[2])
+ | -INTVAL (operands[3])), false)
+ <= riscv_const_insns (operands[3], false)))"
"#"
"&& reload_completed"
[(set (match_dup 4) (match_dup 5))
diff --git a/gcc/testsuite/gcc.target/riscv/pr118122.c b/gcc/testsuite/gcc.target/riscv/pr118122.c
new file mode 100644
index 0000000..0cdc3bf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr118122.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fno-tree-ter -fno-forward-propagate" } */
+char c;
+
+void
+foo(short s)
+{
+ s += 34231u;
+ c = s;
+}
+
+