diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-01-11 21:18:00 +0000 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-01-11 21:18:00 +0000 |
commit | 9f6e9cf71bee19c65817965c4334b6fa5ea9d50f (patch) | |
tree | 2a81a4ec7b71a92f8297f355f323dc91a250fc73 /llvm/test/Transforms/ConstProp/overflow-ops.ll | |
parent | c3399db63d159fe28ce4d5e23c3dd9e305ad8523 (diff) | |
download | bcm5719-llvm-9f6e9cf71bee19c65817965c4334b6fa5ea9d50f.tar.gz bcm5719-llvm-9f6e9cf71bee19c65817965c4334b6fa5ea9d50f.zip |
[ConstantFolding] Fold undef for integer intrinsics
This fixes https://bugs.llvm.org/show_bug.cgi?id=40110.
This implements handling of undef operands for integer intrinsics in
ConstantFolding, in particular for the bitcounting intrinsics (ctpop,
cttz, ctlz), the with.overflow intrinsics, the saturating math
intrinsics and the funnel shift intrinsics.
The undef behavior follows what InstSimplify does for the general cas
e of non-constant operands. For the bitcount intrinsics (where
InstSimplify doesn't do undef handling -- there cannot be a combination
of an undef + non-constant operand) I'm using a 0 result if the intrinsic
is defined for zero and undef otherwise.
Differential Revision: https://reviews.llvm.org/D55950
llvm-svn: 350971
Diffstat (limited to 'llvm/test/Transforms/ConstProp/overflow-ops.ll')
-rw-r--r-- | llvm/test/Transforms/ConstProp/overflow-ops.ll | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/llvm/test/Transforms/ConstProp/overflow-ops.ll b/llvm/test/Transforms/ConstProp/overflow-ops.ll index 087a806a340..303b3b90ab3 100644 --- a/llvm/test/Transforms/ConstProp/overflow-ops.ll +++ b/llvm/test/Transforms/ConstProp/overflow-ops.ll @@ -31,8 +31,7 @@ define {i8, i1} @uadd_2() nounwind { define {i8, i1} @uadd_undef() nounwind { ; CHECK-LABEL: @uadd_undef( -; CHECK-NEXT: [[T:%.*]] = call { i8, i1 } @llvm.uadd.with.overflow.i8(i8 -114, i8 undef) -; CHECK-NEXT: ret { i8, i1 } [[T]] +; CHECK-NEXT: ret { i8, i1 } undef ; %t = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 142, i8 undef) ret {i8, i1} %t @@ -60,8 +59,7 @@ define {i8, i1} @usub_2() nounwind { define {i8, i1} @usub_undef() nounwind { ; CHECK-LABEL: @usub_undef( -; CHECK-NEXT: [[T:%.*]] = call { i8, i1 } @llvm.usub.with.overflow.i8(i8 4, i8 undef) -; CHECK-NEXT: ret { i8, i1 } [[T]] +; CHECK-NEXT: ret { i8, i1 } undef ; %t = call {i8, i1} @llvm.usub.with.overflow.i8(i8 4, i8 undef) ret {i8, i1} %t @@ -89,8 +87,7 @@ define {i8, i1} @umul_2() nounwind { define {i8, i1} @umul_undef() nounwind { ; CHECK-LABEL: @umul_undef( -; CHECK-NEXT: [[T:%.*]] = call { i8, i1 } @llvm.umul.with.overflow.i8(i8 undef, i8 2) -; CHECK-NEXT: ret { i8, i1 } [[T]] +; CHECK-NEXT: ret { i8, i1 } zeroinitializer ; %t = call {i8, i1} @llvm.umul.with.overflow.i8(i8 undef, i8 2) ret {i8, i1} %t @@ -98,8 +95,7 @@ define {i8, i1} @umul_undef() nounwind { define {i8, i1} @umul_both_undef() nounwind { ; CHECK-LABEL: @umul_both_undef( -; CHECK-NEXT: [[T:%.*]] = call { i8, i1 } @llvm.umul.with.overflow.i8(i8 undef, i8 undef) -; CHECK-NEXT: ret { i8, i1 } [[T]] +; CHECK-NEXT: ret { i8, i1 } zeroinitializer ; %t = call {i8, i1} @llvm.umul.with.overflow.i8(i8 undef, i8 undef) ret {i8, i1} %t @@ -151,8 +147,7 @@ define {i8, i1} @sadd_5() nounwind { define {i8, i1} @sadd_undef() nounwind { ; CHECK-LABEL: @sadd_undef( -; CHECK-NEXT: [[T:%.*]] = call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 undef, i8 -10) -; CHECK-NEXT: ret { i8, i1 } [[T]] +; CHECK-NEXT: ret { i8, i1 } undef ; %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 undef, i8 -10) ret {i8, i1} %t @@ -220,8 +215,7 @@ define {i8, i1} @ssub_5() nounwind { define {i8, i1} @ssub_undef() nounwind { ; CHECK-LABEL: @ssub_undef( -; CHECK-NEXT: [[T:%.*]] = call { i8, i1 } @llvm.ssub.with.overflow.i8(i8 undef, i8 -10) -; CHECK-NEXT: ret { i8, i1 } [[T]] +; CHECK-NEXT: ret { i8, i1 } undef ; %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 undef, i8 -10) ret {i8, i1} %t @@ -241,8 +235,7 @@ define {i8, i1} @smul_1() nounwind { define {i8, i1} @smul_undef() nounwind { ; CHECK-LABEL: @smul_undef( -; CHECK-NEXT: [[T:%.*]] = call { i8, i1 } @llvm.smul.with.overflow.i8(i8 -20, i8 undef) -; CHECK-NEXT: ret { i8, i1 } [[T]] +; CHECK-NEXT: ret { i8, i1 } zeroinitializer ; %t = call {i8, i1} @llvm.smul.with.overflow.i8(i8 -20, i8 undef) ret {i8, i1} %t @@ -250,8 +243,7 @@ define {i8, i1} @smul_undef() nounwind { define {i8, i1} @smul_both_undef() nounwind { ; CHECK-LABEL: @smul_both_undef( -; CHECK-NEXT: [[T:%.*]] = call { i8, i1 } @llvm.smul.with.overflow.i8(i8 undef, i8 undef) -; CHECK-NEXT: ret { i8, i1 } [[T]] +; CHECK-NEXT: ret { i8, i1 } zeroinitializer ; %t = call {i8, i1} @llvm.smul.with.overflow.i8(i8 undef, i8 undef) ret {i8, i1} %t |