aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/riscv/pr108016.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.target/riscv/pr108016.c')
-rw-r--r--gcc/testsuite/gcc.target/riscv/pr108016.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/riscv/pr108016.c b/gcc/testsuite/gcc.target/riscv/pr108016.c
new file mode 100644
index 0000000..b60df42
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr108016.c
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc -mabi=lp64" } */
+/* { dg-skip-if "" { *-*-* } { "-O0" } } */
+
+unsigned int addu (unsigned int a, unsigned int b)
+{
+ unsigned int out;
+ unsigned int overflow = __builtin_add_overflow (a, b, &out);
+ return overflow & out;
+}
+
+int addi (int a, int b)
+{
+ int out;
+ int overflow = __builtin_add_overflow (a, b, &out);
+ return overflow & out;
+}
+
+unsigned int subu (unsigned int a, unsigned int b)
+{
+ unsigned int out;
+ unsigned int overflow = __builtin_sub_overflow (a, b, &out);
+ return overflow & out;
+}
+
+int subi (int a, int b)
+{
+ int out;
+ int overflow = __builtin_sub_overflow (a, b, &out);
+ return overflow & out;
+}
+
+/* { dg-final { scan-assembler-not "sext\.w\t" } } */