i386: Fix abs an maxmin expanders for TARGET_PARTIAL_REG_STALL [PR98079].
authorUros Bizjak <ubizjak@gmail.com>
Wed, 2 Dec 2020 07:15:03 +0000 (08:15 +0100)
committerUros Bizjak <ubizjak@gmail.com>
Wed, 2 Dec 2020 07:28:11 +0000 (08:28 +0100)
QImode shold be enabled only for !TARGET_PARTIAL_REG_STALL

2020-12-02  Uroš Bizjak  <ubizjak@gmail.com>

PR target/98079

gcc/
* config/i386/i386.md (abs<mode>2): Enable QImode
only for !TARGET_PARTIAL_REG_STALL.
(*abs<mode>2_1): Ditto.
(<maxmin:code><mode>3): Ditto.
(*<maxmin:code><mode>3_1): Ditto.

gcc/testsuite/
* gcc.target/i386/pr98079.c: New test.

gcc/config/i386/i386.md
gcc/testsuite/gcc.target/i386/pr98079.c [new file with mode: 0644]

index 7c25ae2078d1337d505c82fc49e65b11617cd4f1..76e9499ad74f2991d01b98ede5492caf8cdf274f 100644 (file)
          (abs:SDWIM
            (match_operand:SDWIM 1 "general_operand")))
      (clobber (reg:CC FLAGS_REG))])]
-  "TARGET_CMOVE"
+  "TARGET_CMOVE
+   && (<MODE>mode != QImode || !TARGET_PARTIAL_REG_STALL)"
 {
   if (TARGET_EXPAND_ABS)
     {
          (match_operand:SWI 1 "general_operand")))
    (clobber (reg:CC FLAGS_REG))]
   "TARGET_CMOVE
+   && (<MODE>mode != QImode || !TARGET_PARTIAL_REG_STALL)
    && ix86_pre_reload_split ()"
    "#"
    "&& 1"
            (match_operand:SDWIM 1 "register_operand")
            (match_operand:SDWIM 2 "general_operand")))
      (clobber (reg:CC FLAGS_REG))])]
-  "TARGET_CMOVE")
+  "TARGET_CMOVE
+   && (<MODE>mode != QImode || !TARGET_PARTIAL_REG_STALL)")
 
 (define_insn_and_split "*<code><dwi>3_doubleword"
   [(set (match_operand:<DWI> 0 "register_operand")
          (match_operand:SWI 2 "general_operand")))
    (clobber (reg:CC FLAGS_REG))]
   "TARGET_CMOVE
+   && (<MODE>mode != QImode || !TARGET_PARTIAL_REG_STALL)
    && ix86_pre_reload_split ()"
   "#"
   "&& 1"
diff --git a/gcc/testsuite/gcc.target/i386/pr98079.c b/gcc/testsuite/gcc.target/i386/pr98079.c
new file mode 100644 (file)
index 0000000..8de0ec3
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR target/98079 */
+/* { dg-do compile { target ia32 } } */
+/* { dg-options "-O2 -march=pentium3" } */
+
+typedef __UINT8_TYPE__ uint8_t;
+
+uint8_t foo (uint8_t x)
+{
+  if (x & 0x80)
+    x = -x;
+
+  return x;
+}