forked from OSchip/llvm-project
[InstCombine] handle zero constant vectors for LE/GE comparisons too
Enhancement to: http://reviews.llvm.org/rL269426 With discussion in: http://reviews.llvm.org/D17859 This should complete the fixes for: PR26701, PR26819: https://llvm.org/bugs/show_bug.cgi?id=26701 https://llvm.org/bugs/show_bug.cgi?id=26819 llvm-svn: 269439
This commit is contained in:
parent
27dba61ff3
commit
0c8f3f9332
|
@ -3130,8 +3130,9 @@ static ICmpInst *canonicalizeCmpWithConstant(ICmpInst &I,
|
|||
}
|
||||
|
||||
// The usual vector types are ConstantDataVector. Exotic vector types are
|
||||
// ConstantVector. They both derive from Constant.
|
||||
if (isa<ConstantDataVector>(Op1) || isa<ConstantVector>(Op1)) {
|
||||
// ConstantVector. Zeros are special. They all derive from Constant.
|
||||
if (isa<ConstantDataVector>(Op1) || isa<ConstantVector>(Op1) ||
|
||||
isa<ConstantAggregateZero>(Op1)) {
|
||||
Constant *Op1C = cast<Constant>(Op1);
|
||||
Type *Op1Type = Op1->getType();
|
||||
unsigned NumElts = Op1Type->getVectorNumElements();
|
||||
|
|
|
@ -42,6 +42,43 @@ define <2 x i1> @ule(<2 x i8> %x) {
|
|||
ret <2 x i1> %cmp
|
||||
}
|
||||
|
||||
; Zeros are special: they're ConstantAggregateZero.
|
||||
|
||||
define <2 x i1> @sge_zero(<2 x i8> %x) {
|
||||
; CHECK-LABEL: @sge_zero(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <2 x i8> %x, <i8 -1, i8 -1>
|
||||
; CHECK-NEXT: ret <2 x i1> [[CMP]]
|
||||
;
|
||||
%cmp = icmp sge <2 x i8> %x, <i8 0, i8 0>
|
||||
ret <2 x i1> %cmp
|
||||
}
|
||||
|
||||
define <2 x i1> @uge_zero(<2 x i8> %x) {
|
||||
; CHECK-LABEL: @uge_zero(
|
||||
; CHECK-NEXT: ret <2 x i1> <i1 true, i1 true>
|
||||
;
|
||||
%cmp = icmp uge <2 x i8> %x, <i8 0, i8 0>
|
||||
ret <2 x i1> %cmp
|
||||
}
|
||||
|
||||
define <2 x i1> @sle_zero(<2 x i8> %x) {
|
||||
; CHECK-LABEL: @sle_zero(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i8> %x, <i8 1, i8 1>
|
||||
; CHECK-NEXT: ret <2 x i1> [[CMP]]
|
||||
;
|
||||
%cmp = icmp sle <2 x i8> %x, <i8 0, i8 0>
|
||||
ret <2 x i1> %cmp
|
||||
}
|
||||
|
||||
define <2 x i1> @ule_zero(<2 x i8> %x) {
|
||||
; CHECK-LABEL: @ule_zero(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp ult <2 x i8> %x, <i8 1, i8 1>
|
||||
; CHECK-NEXT: ret <2 x i1> [[CMP]]
|
||||
;
|
||||
%cmp = icmp ule <2 x i8> %x, <i8 0, i8 0>
|
||||
ret <2 x i1> %cmp
|
||||
}
|
||||
|
||||
; Weird types are ConstantVectors, not ConstantDataVectors. For an i3 type:
|
||||
; Signed min = -4
|
||||
; Unsigned min = 0
|
||||
|
|
Loading…
Reference in New Issue