Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Unified Diff: test/Transforms/NaCl/expand-arith-with-overflow.ll

Issue 15688011: PNaCl: Extend ExpandMulWithOverflow pass to handle uadd.with.overflow too (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Rebase Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/Transforms/NaCl/PNaClABISimplify.cpp ('k') | test/Transforms/NaCl/expand-mul-with-overflow.ll » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/Transforms/NaCl/expand-arith-with-overflow.ll
diff --git a/test/Transforms/NaCl/expand-mul-with-overflow.ll b/test/Transforms/NaCl/expand-arith-with-overflow.ll
similarity index 64%
rename from test/Transforms/NaCl/expand-mul-with-overflow.ll
rename to test/Transforms/NaCl/expand-arith-with-overflow.ll
index f6957988b0af994aa18e5774512eedb18e8bd34e..d3bb8f039292746ed70337c43a041141179e6734 100644
--- a/test/Transforms/NaCl/expand-mul-with-overflow.ll
+++ b/test/Transforms/NaCl/expand-arith-with-overflow.ll
@@ -1,9 +1,10 @@
-; RUN: opt %s -expand-mul-with-overflow -S | FileCheck %s
+; RUN: opt %s -expand-arith-with-overflow -S | FileCheck %s
declare {i32, i1} @llvm.umul.with.overflow.i32(i32, i32)
declare {i64, i1} @llvm.umul.with.overflow.i64(i64, i64)
+declare {i16, i1} @llvm.uadd.with.overflow.i16(i16, i16)
-; CHECK-NOT: @llvm.umul.with.overflow
+; CHECK-NOT: with.overflow
define void @umul32_by_const(i32 %x, i32* %result_val, i1* %result_overflow) {
@@ -18,9 +19,9 @@ define void @umul32_by_const(i32 %x, i32* %result_val, i1* %result_overflow) {
; The bound is 16777215 == 0xffffff == ((1 << 32) - 1) / 256
; CHECK: define void @umul32_by_const(
-; CHECK-NEXT: %pair.mul = mul i32 %x, 256
+; CHECK-NEXT: %pair.arith = mul i32 %x, 256
; CHECK-NEXT: %pair.overflow = icmp ugt i32 %x, 16777215
-; CHECK-NEXT: store i32 %pair.mul, i32* %result_val
+; CHECK-NEXT: store i32 %pair.arith, i32* %result_val
; CHECK-NEXT: store i1 %pair.overflow, i1* %result_overflow
@@ -39,9 +40,9 @@ define void @umul32_by_const2(i32 %x, i32* %result_val, i1* %result_overflow) {
}
; CHECK: define void @umul32_by_const2(
-; CHECK-NEXT: %pair.mul = mul i32 %x, 65536
+; CHECK-NEXT: %pair.arith = mul i32 %x, 65536
; CHECK-NEXT: %pair.overflow = icmp ugt i32 %x, 65535
-; CHECK-NEXT: store i32 %pair.mul, i32* %result_val
+; CHECK-NEXT: store i32 %pair.arith, i32* %result_val
; CHECK-NEXT: store i1 %pair.overflow, i1* %result_overflow
; CHECK-NEXT: store i1 %pair.overflow, i1* %result_overflow
@@ -58,7 +59,23 @@ define void @umul64_by_const(i64 %x, i64* %result_val, i1* %result_overflow) {
}
; CHECK: define void @umul64_by_const(i64 %x, i64* %result_val, i1* %result_overflow) {
-; CHECK-NEXT: %pair.mul = mul i64 %x, 36028797018963968
+; CHECK-NEXT: %pair.arith = mul i64 %x, 36028797018963968
; CHECK-NEXT: %pair.overflow = icmp ugt i64 %x, 511
-; CHECK-NEXT: store i64 %pair.mul, i64* %result_val
+; CHECK-NEXT: store i64 %pair.arith, i64* %result_val
+; CHECK-NEXT: store i1 %pair.overflow, i1* %result_overflow
+
+
+define void @uadd16_with_const(i16 %x, i16* %result_val, i1* %result_overflow) {
+ %pair = call {i16, i1} @llvm.uadd.with.overflow.i16(i16 %x, i16 35)
+ %val = extractvalue {i16, i1} %pair, 0
+ %overflow = extractvalue {i16, i1} %pair, 1
+
+ store i16 %val, i16* %result_val
+ store i1 %overflow, i1* %result_overflow
+ ret void
+}
+; CHECK: define void @uadd16_with_const(i16 %x, i16* %result_val, i1* %result_overflow) {
+; CHECK-NEXT: %pair.arith = add i16 %x, 35
+; CHECK-NEXT: %pair.overflow = icmp ugt i16 %x, -36
+; CHECK-NEXT: store i16 %pair.arith, i16* %result_val
; CHECK-NEXT: store i1 %pair.overflow, i1* %result_overflow
« no previous file with comments | « lib/Transforms/NaCl/PNaClABISimplify.cpp ('k') | test/Transforms/NaCl/expand-mul-with-overflow.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698