aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2008-02-18 22:48:05 +0000
committerNick Lewycky <nicholas@mxc.ca>2008-02-18 22:48:05 +0000
commite0cfecf47d466b5776371526c27969e07177b839 (patch)
treea4f75ff0026e3e2935d8f68ac2e42385a490f17d /test/Transforms
parentb00ee21f21858c18af20fd57c7a5e2a6d38ff70c (diff)
downloadexternal_llvm-e0cfecf47d466b5776371526c27969e07177b839.zip
external_llvm-e0cfecf47d466b5776371526c27969e07177b839.tar.gz
external_llvm-e0cfecf47d466b5776371526c27969e07177b839.tar.bz2
Correctly fold divide-by-constant, even when faced with overflow.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47287 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms')
-rw-r--r--test/Transforms/InstCombine/2008-02-16-SDivOverflow.ll14
-rw-r--r--test/Transforms/InstCombine/2008-02-16-SDivOverflow2.ll9
2 files changed, 23 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/2008-02-16-SDivOverflow.ll b/test/Transforms/InstCombine/2008-02-16-SDivOverflow.ll
new file mode 100644
index 0000000..cd61a10
--- /dev/null
+++ b/test/Transforms/InstCombine/2008-02-16-SDivOverflow.ll
@@ -0,0 +1,14 @@
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {ret i.* 0} | count 2
+; PR2048
+
+define i32 @i(i32 %a) {
+ %tmp1 = sdiv i32 %a, -1431655765
+ %tmp2 = sdiv i32 %tmp1, 3
+ ret i32 %tmp2
+}
+
+define i8 @j(i8 %a) {
+ %tmp1 = sdiv i8 %a, 64
+ %tmp2 = sdiv i8 %tmp1, 3
+ ret i8 %tmp2
+}
diff --git a/test/Transforms/InstCombine/2008-02-16-SDivOverflow2.ll b/test/Transforms/InstCombine/2008-02-16-SDivOverflow2.ll
new file mode 100644
index 0000000..0e260c4
--- /dev/null
+++ b/test/Transforms/InstCombine/2008-02-16-SDivOverflow2.ll
@@ -0,0 +1,9 @@
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {sdiv i8 \%a, 9}
+; PR2048
+
+define i8 @i(i8 %a) {
+ %tmp1 = sdiv i8 %a, -3
+ %tmp2 = sdiv i8 %tmp1, -3
+ ret i8 %tmp2
+}
+