summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2016-05-17 00:57:57 +0000
committerSanjay Patel <spatel@rotateright.com>2016-05-17 00:57:57 +0000
commite9b2c32e7f0faa0c31c2c1cb44cbe9c9e234cd64 (patch)
tree5bc4a70bf6e491b86cba60adf8d0bfc92191fa9e /llvm/test
parent4940f87bcc1aa3aa048b3c38c7013d7a385cac4f (diff)
downloadbcm5719-llvm-e9b2c32e7f0faa0c31c2c1cb44cbe9c9e234cd64.tar.gz
bcm5719-llvm-e9b2c32e7f0faa0c31c2c1cb44cbe9c9e234cd64.zip
[InstCombine] check vector elements before trying to transform LE/GE vector icmp (PR27756)
Fix a bug introduced with rL269426 : [InstCombine] canonicalize* LE/GE vector integer comparisons to LT/GT (PR26701, PR26819) We were assuming that a ConstantDataVector / ConstantVector / ConstantAggregateZero operand of an ICMP was composed of ConstantInt elements, but it might have ConstantExpr or UndefValue elements. Handle those appropriately. Also, refactor this function to join the scalar and vector paths and eliminate the switches. Differential Revision: http://reviews.llvm.org/D20289 llvm-svn: 269728
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/InstCombine/icmp-vec.ll22
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/icmp-vec.ll b/llvm/test/Transforms/InstCombine/icmp-vec.ll
index df653caa56d..290eacebe9d 100644
--- a/llvm/test/Transforms/InstCombine/icmp-vec.ll
+++ b/llvm/test/Transforms/InstCombine/icmp-vec.ll
@@ -159,3 +159,25 @@ define <2 x i1> @ule_max(<2 x i3> %x) {
ret <2 x i1> %cmp
}
+; If we can't determine if a constant element is min/max (eg, it's a ConstantExpr), do nothing.
+
+define <2 x i1> @PR27756_1(<2 x i8> %a) {
+; CHECK-LABEL: @PR27756_1(
+; CHECK-NEXT: [[CMP:%.*]] = icmp sle <2 x i8> %a, <i8 bitcast (<2 x i4> <i4 1, i4 2> to i8), i8 0>
+; CHECK-NEXT: ret <2 x i1> [[CMP]]
+;
+ %cmp = icmp sle <2 x i8> %a, <i8 bitcast (<2 x i4> <i4 1, i4 2> to i8), i8 0>
+ ret <2 x i1> %cmp
+}
+
+; Undef elements don't prevent the transform of the comparison.
+
+define <2 x i1> @PR27756_2(<2 x i8> %a) {
+; CHECK-LABEL: @PR27756_2(
+; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i8> %a, <i8 undef, i8 1>
+; CHECK-NEXT: ret <2 x i1> [[CMP]]
+;
+ %cmp = icmp sle <2 x i8> %a, <i8 undef, i8 0>
+ ret <2 x i1> %cmp
+}
+
OpenPOWER on IntegriCloud