]> gcc.gnu.org Git - gcc.git/commitdiff
rs6000: using pli for constant splitting
authorJiufu Guo <guojiufu@linux.ibm.com>
Wed, 13 Dec 2023 00:10:25 +0000 (08:10 +0800)
committerguojiufu <guojiufu@linux.ibm.com>
Wed, 13 Dec 2023 00:53:18 +0000 (08:53 +0800)
For constant building e.g. r120=0x66666666, which does not fit 'li or lis',
'pli' is used to build this constant via 'emit_move_insn'.

While for a complicated constant, e.g. 0x6666666666666666ULL, when using
'rs6000_emit_set_long_const' to split the constant recursively, it fails to
use 'pli' to build the half part constant: 0x66666666.

'rs6000_emit_set_long_const' could be updated to use 'pli' to build half
part of the constant when necessary.  For example: 0x6666666666666666ULL,
"pli 3,1717986918; rldimi 3,3,32,0" can be used.

gcc/ChangeLog:

* config/rs6000/rs6000.cc (rs6000_emit_set_long_const): Add code to use
pli for 34bit constant.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/const-build-1.c: New test.

gcc/config/rs6000/rs6000.cc
gcc/testsuite/gcc.target/powerpc/const-build-1.c [new file with mode: 0644]

index 5cb94f6c0d667576c275c99b6c3ab4214ec7dd5b..09a5d29ec8ca1f344c46f073a5b1a9f93a7ed6ce 100644 (file)
@@ -10521,6 +10521,13 @@ rs6000_emit_set_long_const (rtx dest, HOST_WIDE_INT c, int *num_insns)
       emit_insn (dest_or_insn);
   };
 
+  if (TARGET_PREFIXED && SIGNED_INTEGER_34BIT_P (c))
+    {
+      /* li/lis/pli */
+      count_or_emit_insn (dest, GEN_INT (c));
+      return;
+    }
+
   if ((ud4 == 0xffff && ud3 == 0xffff && ud2 == 0xffff && (ud1 & 0x8000))
       || (ud4 == 0 && ud3 == 0 && ud2 == 0 && !(ud1 & 0x8000)))
     {
diff --git a/gcc/testsuite/gcc.target/powerpc/const-build-1.c b/gcc/testsuite/gcc.target/powerpc/const-build-1.c
new file mode 100644 (file)
index 0000000..7e35f8c
--- /dev/null
@@ -0,0 +1,9 @@
+/* { dg-do compile { target lp64 } } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+/* { dg-require-effective-target power10_ok } */
+
+unsigned long long msk66() { return 0x6666666666666666ULL; }
+
+/* { dg-final { scan-assembler-times {\mpli\M} 1 } } */
+/* { dg-final { scan-assembler-not {\mli\M} } } */
+/* { dg-final { scan-assembler-not {\mlis\M} } } */
This page took 0.086569 seconds and 5 git commands to generate.