]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: Add new variant of pr42196-3.c
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Sat, 3 Jan 2026 23:09:40 +0000 (15:09 -0800)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Sat, 3 Jan 2026 23:16:48 +0000 (15:16 -0800)
While working on complex lowering, I noticed that the
testcase pr42196-3.c had some interesting code in it
and most likely a copy and pasto. Since this testcase
was added back in 2009, I rather add a new testcase
rather than changing the old one.
The testcase was doing:
```
  if (b)
    {
      f1 = __real__ u.cf;
      f1 = __imag__ u.cf;
    }
  else
    {
      f1 = __real__ u.ci;
      f1 = __imag__ u.ci;
    }

  r = bar (f1, f2);
```
I suspect the second f1 in both sides of the conditional
were supposed to be f2. So the new testcase does that.

Tested on x86_64-linux-gnu and pushed as obvious.

PR tree-optimization/42196

gcc/testsuite/ChangeLog:

* gcc.c-torture/compile/pr42196-4.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
gcc/testsuite/gcc.c-torture/compile/pr42196-4.c [new file with mode: 0644]

diff --git a/gcc/testsuite/gcc.c-torture/compile/pr42196-4.c b/gcc/testsuite/gcc.c-torture/compile/pr42196-4.c
new file mode 100644 (file)
index 0000000..d7e526c
--- /dev/null
@@ -0,0 +1,27 @@
+union U
+{
+  __complex__ int ci;
+  __complex__ float cf;
+};
+
+float gd;
+extern float bar (float, float);
+
+float foo (int b, union U u)
+{
+  float f1, f2, r;
+
+  if (b)
+    {
+      f1 = __real__ u.cf;
+      f2 = __imag__ u.cf;
+    }
+  else
+    {
+      f1 = __real__ u.ci;
+      f2 = __imag__ u.ci;
+    }
+
+  r = bar (f1, f2);
+  return r;
+}