about summary refs log tree commit diff homepage
path: root/test
diff options
context:
space:
mode:
authorCristian Cadar <c.cadar@imperial.ac.uk>2015-09-21 18:52:15 +0200
committerCristian Cadar <c.cadar@imperial.ac.uk>2015-09-21 18:52:15 +0200
commite8fded10ccdaea3d9d72d178506d6aebb799394e (patch)
tree1a3314b28fe9d021eee1c8555e4fff4e81104e63 /test
parent090cd7310cf8257081c87a64985d588bd749566b (diff)
parent5c211bf969a6ae6b549d0a53daf4c99870c82210 (diff)
downloadklee-e8fded10ccdaea3d9d72d178506d6aebb799394e.tar.gz
Merge pull request #274 from MartinNowack/fix_sdiv_1
Fix signed division by constant 1/ -1
Diffstat (limited to 'test')
-rw-r--r--test/regression/2015-08-30-sdiv-1.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/regression/2015-08-30-sdiv-1.c b/test/regression/2015-08-30-sdiv-1.c
new file mode 100644
index 00000000..a90df308
--- /dev/null
+++ b/test/regression/2015-08-30-sdiv-1.c
@@ -0,0 +1,19 @@
+// RUN: %llvmgcc %s -emit-llvm -g -O0 -c -o %t.bc
+// RUN: rm -rf %t.klee-out
+// RUN: %klee --output-dir=%t.klee-out -exit-on-error -solver-optimize-divides=true %t.bc
+// RUN: rm -rf %t.klee-out
+// RUN: %klee --output-dir=%t.klee-out -exit-on-error -solver-optimize-divides=false %t.bc
+
+/* Division by constant can be optimized.using mul/shift
+ * For signed division, div by 1 or -1 cannot be optimized like that.
+ */
+#include <stdint.h>
+int main() {
+  int32_t dividend;
+  klee_make_symbolic(&dividend, sizeof dividend, "Dividend");
+  if ((3 ^ (dividend & 2)) / 1)
+    return 1;
+  if ((3 ^ (dividend & 2)) / -1)
+    return 1;
+  return 0;
+}