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