aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Pinski <apinski@marvell.com>2023-05-10 17:56:15 +0000
committerAndrew Pinski <apinski@marvell.com>2023-05-10 17:56:15 +0000
commite91937e9a480b8a765ba26865eb000b8e6aa1fce (patch)
tree9292b90222925d6366f8c4789831c6ac1fd547a3
parent5476c9142830d01c4b8f2d91e9d439cb32d76378 (diff)
downloadgcc-e91937e9a480b8a765ba26865eb000b8e6aa1fce.zip
gcc-e91937e9a480b8a765ba26865eb000b8e6aa1fce.tar.gz
gcc-e91937e9a480b8a765ba26865eb000b8e6aa1fce.tar.bz2
Add another new testcase
While working on improving min/max detection, this code (which is reduced from worse_state in ipa-pure-const.cc) was being miscompiled. Since there was no testcase in the testsuite yet for this, this patch adds one. Committed as obvious after testing the testcase via: make check-gcc RUNTESTFLAGS="execute.exp=20230510-1.c" gcc/testsuite/ChangeLog: * gcc.c-torture/execute/20230510-1.c: New test.
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20230510-1.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/execute/20230510-1.c b/gcc/testsuite/gcc.c-torture/execute/20230510-1.c
new file mode 100644
index 0000000..ec9c9e6
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20230510-1.c
@@ -0,0 +1,34 @@
+/* This code shows up in worse_state in ipa-pure-const.cc:
+ *looping = MAX (*looping, looping2);
+ was miscompiling it as just `return 1` though instead of
+ `MAX_EXPR<*a, b>` (which should be transformed into `*a | b`
+ note MAX_EXPR<bool, bool> is really `bool | bool` so we
+ use that to compare against here.
+ */
+#define bool _Bool
+bool __attribute__((noipa)) f(bool *a, bool b)
+{
+ bool t = *a;
+ if (t <= b)
+ return b;
+ return t;
+}
+bool __attribute__((noipa)) f1(bool *a, bool b)
+{
+ return *a | b;
+}
+
+int main()
+{
+ int i = 0;
+ int j = 0;
+
+ for (i = 0; i <= 1; i++)
+ for (j = 0; j <= 1; j++)
+ {
+ bool a = i;
+ if (f(&a, j) != f1(&a, j))
+ __builtin_abort();
+ }
+ return 0;
+}