|
|
9fbc78 |
commit 6c175b3d170de2bb02b7bd45b3348eec05d28451
|
|
|
9fbc78 |
Author: Roger Sayle <roger@nextmovesoftware.com>
|
|
|
9fbc78 |
Date: Mon Jul 4 13:58:37 2022 +0100
|
|
|
9fbc78 |
|
|
|
9fbc78 |
PR target/105991: Recognize PLUS and XOR forms of rldimi in rs6000.md.
|
|
|
9fbc78 |
|
|
|
9fbc78 |
This patch addresses PR target/105991 where a change to prefer representing
|
|
|
9fbc78 |
shifts and adds at the tree-level as multiplications, causes problems for
|
|
|
9fbc78 |
the rldimi patterns in the powerpc backend. The issue is that rs6000.md
|
|
|
9fbc78 |
models this pattern using IOR, and some variants that have the equivalent
|
|
|
9fbc78 |
PLUS or XOR in the RTL fail to match some *rotl<mode>4_insert patterns.
|
|
|
9fbc78 |
This is fixed in this patch by adding a define_insn_and_split to locally
|
|
|
9fbc78 |
canonicalize the PLUS and XOR forms to the backend's preferred IOR form.
|
|
|
9fbc78 |
|
|
|
9fbc78 |
Backported from master.
|
|
|
9fbc78 |
|
|
|
9fbc78 |
2022-07-04 Roger Sayle <roger@nextmovesoftware.com>
|
|
|
9fbc78 |
Marek Polacek <polacek@redhat.com>
|
|
|
9fbc78 |
Segher Boessenkool <segher@kernel.crashing.org>
|
|
|
9fbc78 |
Kewen Lin <linkw@linux.ibm.com>
|
|
|
9fbc78 |
|
|
|
9fbc78 |
gcc/ChangeLog
|
|
|
9fbc78 |
PR target/105991
|
|
|
9fbc78 |
* config/rs6000/rs6000.md (rotl<mode>3_insert_3): Check that
|
|
|
9fbc78 |
exact_log2 doesn't return -1 (or zero).
|
|
|
9fbc78 |
(plus_xor): New code iterator.
|
|
|
9fbc78 |
(*rotl<mode>3_insert_3_): New define_insn_and_split.
|
|
|
9fbc78 |
|
|
|
9fbc78 |
gcc/testsuite/ChangeLog
|
|
|
9fbc78 |
PR target/105991
|
|
|
9fbc78 |
* gcc.target/powerpc/pr105991.c: New test case.
|
|
|
9fbc78 |
|
|
|
9fbc78 |
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
|
|
|
9fbc78 |
index 64049a6e521..6082ded8c31 100644
|
|
|
9fbc78 |
--- a/gcc/config/rs6000/rs6000.md
|
|
|
9fbc78 |
+++ b/gcc/config/rs6000/rs6000.md
|
|
|
9fbc78 |
@@ -4178,7 +4178,8 @@ (define_insn "rotl<mode>3_insert_3"
|
|
|
9fbc78 |
(match_operand:GPR 4 "const_int_operand" "n"))
|
|
|
9fbc78 |
(ashift:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
|
|
|
9fbc78 |
(match_operand:SI 2 "const_int_operand" "n"))))]
|
|
|
9fbc78 |
- "INTVAL (operands[2]) == exact_log2 (UINTVAL (operands[4]) + 1)"
|
|
|
9fbc78 |
+ "INTVAL (operands[2]) > 0
|
|
|
9fbc78 |
+ && INTVAL (operands[2]) == exact_log2 (UINTVAL (operands[4]) + 1)"
|
|
|
9fbc78 |
{
|
|
|
9fbc78 |
if (<MODE>mode == SImode)
|
|
|
9fbc78 |
return "rlwimi %0,%1,%h2,0,31-%h2";
|
|
|
9fbc78 |
@@ -4187,6 +4188,24 @@ (define_insn "rotl<mode>3_insert_3"
|
|
|
9fbc78 |
}
|
|
|
9fbc78 |
[(set_attr "type" "insert")])
|
|
|
9fbc78 |
|
|
|
9fbc78 |
+; Canonicalize the PLUS and XOR forms to IOR for rotl<mode>3_insert_3
|
|
|
9fbc78 |
+(define_code_iterator plus_xor [plus xor])
|
|
|
9fbc78 |
+
|
|
|
9fbc78 |
+(define_insn_and_split "*rotl<mode>3_insert_3_"
|
|
|
9fbc78 |
+ [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
|
|
|
9fbc78 |
+ (plus_xor:GPR
|
|
|
9fbc78 |
+ (and:GPR (match_operand:GPR 3 "gpc_reg_operand" "0")
|
|
|
9fbc78 |
+ (match_operand:GPR 4 "const_int_operand" "n"))
|
|
|
9fbc78 |
+ (ashift:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
|
|
|
9fbc78 |
+ (match_operand:SI 2 "const_int_operand" "n"))))]
|
|
|
9fbc78 |
+ "INTVAL (operands[2]) > 0
|
|
|
9fbc78 |
+ && INTVAL (operands[2]) == exact_log2 (UINTVAL (operands[4]) + 1)"
|
|
|
9fbc78 |
+ "#"
|
|
|
9fbc78 |
+ "&& 1"
|
|
|
9fbc78 |
+ [(set (match_dup 0)
|
|
|
9fbc78 |
+ (ior:GPR (and:GPR (match_dup 3) (match_dup 4))
|
|
|
9fbc78 |
+ (ashift:GPR (match_dup 1) (match_dup 2))))])
|
|
|
9fbc78 |
+
|
|
|
9fbc78 |
(define_code_iterator plus_ior_xor [plus ior xor])
|
|
|
9fbc78 |
|
|
|
9fbc78 |
(define_split
|
|
|
9fbc78 |
diff --git a/gcc/testsuite/gcc.target/powerpc/pr105991.c b/gcc/testsuite/gcc.target/powerpc/pr105991.c
|
|
|
9fbc78 |
new file mode 100644
|
|
|
9fbc78 |
index 00000000000..0d9d130cb63
|
|
|
9fbc78 |
--- /dev/null
|
|
|
9fbc78 |
+++ b/gcc/testsuite/gcc.target/powerpc/pr105991.c
|
|
|
9fbc78 |
@@ -0,0 +1,12 @@
|
|
|
9fbc78 |
+/* { dg-do compile } */
|
|
|
9fbc78 |
+/* { dg-options "-O2" } */
|
|
|
9fbc78 |
+/* { dg-require-effective-target lp64 } */
|
|
|
9fbc78 |
+unsigned long long
|
|
|
9fbc78 |
+foo (unsigned long long value)
|
|
|
9fbc78 |
+{
|
|
|
9fbc78 |
+ value &= 0xffffffff;
|
|
|
9fbc78 |
+ value |= value << 32;
|
|
|
9fbc78 |
+ return value;
|
|
|
9fbc78 |
+}
|
|
|
9fbc78 |
+/* { dg-final { scan-assembler {\mrldimi\M} } } */
|
|
|
9fbc78 |
+
|