summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstCombine
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-05-28 21:43:52 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-05-28 21:43:52 +0000
commit6196b7430e141d06e69f15613f26b9d8feecb911 (patch)
treee3c383351df4d3236644939b07e351e5ab5884e7 /llvm/test/Transforms/InstCombine
parent910528a3eb635223c519fef3e5833a67cffc8232 (diff)
downloadbcm5719-llvm-6196b7430e141d06e69f15613f26b9d8feecb911.tar.gz
bcm5719-llvm-6196b7430e141d06e69f15613f26b9d8feecb911.zip
Revert "Revert "InstCombine: Improvement to check if signed addition overflows.""
This reverts commit r209762, bringing back r209746. It was not responsible for the libc++ build failure llvm-svn: 209776
Diffstat (limited to 'llvm/test/Transforms/InstCombine')
-rw-r--r--llvm/test/Transforms/InstCombine/AddOverflow.ll56
1 files changed, 56 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/AddOverflow.ll b/llvm/test/Transforms/InstCombine/AddOverflow.ll
new file mode 100644
index 00000000000..1bbd1fc59a5
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/AddOverflow.ll
@@ -0,0 +1,56 @@
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; CHECK-LABEL: @ripple(
+; CHECK: add nsw i16 %tmp1, 1
+define i32 @ripple(i16 signext %x) {
+bb:
+ %tmp = sext i16 %x to i32
+ %tmp1 = and i32 %tmp, -5
+ %tmp2 = trunc i32 %tmp1 to i16
+ %tmp3 = sext i16 %tmp2 to i32
+ %tmp4 = add i32 %tmp3, 1
+ ret i32 %tmp4
+}
+
+; CHECK-LABEL: @ripplenot(
+; CHECK: add i32 %tmp3, 4
+define i32 @ripplenot(i16 signext %x) {
+bb:
+ %tmp = sext i16 %x to i32
+ %tmp1 = and i32 %tmp, -3
+ %tmp2 = trunc i32 %tmp1 to i16
+ %tmp3 = sext i16 %tmp2 to i32
+ %tmp4 = add i32 %tmp3, 4
+ ret i32 %tmp4
+}
+
+; CHECK-LABEL: @oppositesign(
+; CHECK: add nsw i16 %tmp1, 4
+define i32 @oppositesign(i16 signext %x) {
+bb:
+ %tmp = sext i16 %x to i32
+ %tmp1 = or i32 %tmp, 32768
+ %tmp2 = trunc i32 %tmp1 to i16
+ %tmp3 = sext i16 %tmp2 to i32
+ %tmp4 = add i32 %tmp3, 4
+ ret i32 %tmp4
+}
+
+; CHECK-LABEL: @ripplenot_var(
+; CHECK: add i32 %tmp6, %tmp7
+define i32 @ripplenot_var(i16 signext %x, i16 signext %y) {
+bb:
+ %tmp = sext i16 %x to i32
+ %tmp1 = and i32 %tmp, -5
+ %tmp2 = trunc i32 %tmp1 to i16
+ %tmp3 = sext i16 %y to i32
+ %tmp4 = or i32 %tmp3, 2
+ %tmp5 = trunc i32 %tmp4 to i16
+ %tmp6 = sext i16 %tmp5 to i32
+ %tmp7 = sext i16 %tmp2 to i32
+ %tmp8 = add i32 %tmp6, %tmp7
+ ret i32 %tmp8
+}
OpenPOWER on IntegriCloud