'enabled' attribute has to be a pass-invariant static property per the
RTL docs, and optimize_function_for_size_p (cfun)'s cgraph frequency/count
term isn't — the same instability PR114232 already fixed for the insn
condition, just missed here in enabled.

PR target/127461

gcc/ChangeLog:

* config/i386/mmx.md (negv2qi2): Use optimize_size instead of
optimize_function_for_size_p (cfun) in the enabled attribute.
(<plusminus:insn>v2qi3): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr127461.c: New test.

Bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32}.

Uros.
diff --git a/gcc/config/i386/mmx.md b/gcc/config/i386/mmx.md
index fc6286cfed2..fa51f6a7991 100644
--- a/gcc/config/i386/mmx.md
+++ b/gcc/config/i386/mmx.md
@@ -3190,7 +3190,7 @@ (define_insn "negv2qi2"
    (set (attr "enabled")
        (cond [(and (eq_attr "alternative" "0")
                    (and (match_test "TARGET_PARTIAL_REG_STALL")
-                        (not (match_test "optimize_function_for_size_p 
(cfun)"))))
+                        (not (match_test "optimize_size"))))
                (symbol_ref "false")
              ]
              (const_string "*")))])
@@ -3297,7 +3297,7 @@ (define_insn "<insn>v2qi3"
    (set (attr "enabled")
        (cond [(and (eq_attr "alternative" "0")
                    (and (match_test "TARGET_PARTIAL_REG_STALL")
-                        (not (match_test "optimize_function_for_size_p 
(cfun)"))))
+                        (not (match_test "optimize_size"))))
                (symbol_ref "false")
              ]
              (const_string "*")))])
diff --git a/gcc/testsuite/gcc.target/i386/pr127461.c 
b/gcc/testsuite/gcc.target/i386/pr127461.c
new file mode 100644
index 00000000000..a0af16c3fb5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr127461.c
@@ -0,0 +1,23 @@
+/* PR target/127461 */
+/* { dg-do compile { target ia32 } } */
+/* { dg-options "-Og -msse2 -mtune=pentiumpro" } */
+
+typedef __attribute__((__vector_size__(2))) char U;
+typedef __attribute__((__vector_size__(2))) _Float16 V;
+typedef __attribute__((__vector_size__(32))) int W;
+
+V a, b;
+extern inline __attribute__((__cold__)) void foo(int, int, double, char ) {
+  (union {W w;}){};
+  U u = (U)b + (U)a;
+  ((union {
+    U a;
+    char b[];
+  })u)
+      .b;
+}
+void main() {
+  foo((int){}, (int){}, (int){}, 0);
+  for (;;)
+    ;
+}

Reply via email to