While I was writting a match.pd patch, I can across GCC was being miscompiled but no testcase was failing. So this adds that testcase.
Committed after testing on x86_64 with make check-gcc RUNTESTFLAGS="execute.exp=20230509-1.c" gcc/testsuite/ChangeLog: * gcc.c-torture/execute/20230509-1.c: New test. --- .../gcc.c-torture/execute/20230509-1.c | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/execute/20230509-1.c diff --git a/gcc/testsuite/gcc.c-torture/execute/20230509-1.c b/gcc/testsuite/gcc.c-torture/execute/20230509-1.c new file mode 100644 index 00000000000..359d93c5d34 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20230509-1.c @@ -0,0 +1,28 @@ +int __attribute__((noipa)) f(unsigned a, int b) +{ + if (a < 0) __builtin_unreachable(); + if (a > 30) __builtin_unreachable(); + int t = a; + if (b) t = 100; + else if (a != 0) + t = a ; + else + t = 1; + return t; +} + + +int main(void) +{ + if (f(0, 0) != 1) + __builtin_abort(); + if (f(1, 0) != 1) + __builtin_abort(); + if (f(0, 1) != 100) + __builtin_abort(); + if (f(1, 0) != 1) + __builtin_abort(); + if (f(30, 0) != 30) + __builtin_abort(); +} + -- 2.31.1