summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-07-01 17:14:37 +0000
committerSanjay Patel <spatel@rotateright.com>2018-07-01 17:14:37 +0000
commit279a1a39ad64c2aefd77e38dd6215b7ef4b94566 (patch)
treee0c33c3bd1490b6b47826c6bf031f06ea9f83cf9
parenta9fdb9fd3786eaa584b0656937bfaad31f47ace4 (diff)
downloadbcm5719-llvm-279a1a39ad64c2aefd77e38dd6215b7ef4b94566.tar.gz
bcm5719-llvm-279a1a39ad64c2aefd77e38dd6215b7ef4b94566.zip
[InstCombine] add abs tests with undef elts; NFC
llvm-svn: 336065
-rw-r--r--llvm/test/Transforms/InstCombine/abs-1.ll30
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/abs-1.ll b/llvm/test/Transforms/InstCombine/abs-1.ll
index 2f773dc2e21..72124e30a57 100644
--- a/llvm/test/Transforms/InstCombine/abs-1.ll
+++ b/llvm/test/Transforms/InstCombine/abs-1.ll
@@ -73,6 +73,21 @@ define <2 x i8> @abs_canonical_2(<2 x i8> %x) {
ret <2 x i8> %abs
}
+; Even if a constant has undef elements.
+
+define <2 x i8> @abs_canonical_2_vec_undef_elts(<2 x i8> %x) {
+; CHECK-LABEL: @abs_canonical_2_vec_undef_elts(
+; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <2 x i8> [[X:%.*]], <i8 undef, i8 -1>
+; CHECK-NEXT: [[NEG:%.*]] = sub <2 x i8> zeroinitializer, [[X]]
+; CHECK-NEXT: [[ABS:%.*]] = select <2 x i1> [[CMP]], <2 x i8> [[X]], <2 x i8> [[NEG]]
+; CHECK-NEXT: ret <2 x i8> [[ABS]]
+;
+ %cmp = icmp sgt <2 x i8> %x, <i8 undef, i8 -1>
+ %neg = sub <2 x i8> zeroinitializer, %x
+ %abs = select <2 x i1> %cmp, <2 x i8> %x, <2 x i8> %neg
+ ret <2 x i8> %abs
+}
+
; NSW should not change.
define i8 @abs_canonical_3(i8 %x) {
@@ -146,6 +161,21 @@ define <2 x i8> @nabs_canonical_2(<2 x i8> %x) {
ret <2 x i8> %abs
}
+; Even if a constant has undef elements.
+
+define <2 x i8> @nabs_canonical_2_vec_undef_elts(<2 x i8> %x) {
+; CHECK-LABEL: @nabs_canonical_2_vec_undef_elts(
+; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <2 x i8> [[X:%.*]], <i8 -1, i8 undef>
+; CHECK-NEXT: [[NEG:%.*]] = sub <2 x i8> zeroinitializer, [[X]]
+; CHECK-NEXT: [[ABS:%.*]] = select <2 x i1> [[CMP]], <2 x i8> [[NEG]], <2 x i8> [[X]]
+; CHECK-NEXT: ret <2 x i8> [[ABS]]
+;
+ %cmp = icmp sgt <2 x i8> %x, <i8 -1, i8 undef>
+ %neg = sub <2 x i8> zeroinitializer, %x
+ %abs = select <2 x i1> %cmp, <2 x i8> %neg, <2 x i8> %x
+ ret <2 x i8> %abs
+}
+
; NSW should not change.
define i8 @nabs_canonical_3(i8 %x) {
OpenPOWER on IntegriCloud