forked from OSchip/llvm-project
[InstCombine] choose 1 form of abs and nabs as canonical
We already do this for min/max (see the blob above the diff), so we should do the same for abs/nabs. A sign-bit check (<s 0) is used as a predicate for other IR transforms and it's likely the best for codegen. This might solve the motivating cases for D47037 and D47041, but I think those patches still make sense. We can't guarantee this canonicalization if the icmp has more than one use. Differential Revision: https://reviews.llvm.org/D47076 llvm-svn: 332819
This commit is contained in:
parent
4a227e582b
commit
a003c728a5
|
@ -794,6 +794,54 @@ canonicalizeMinMaxWithConstant(SelectInst &Sel, ICmpInst &Cmp,
|
|||
return &Sel;
|
||||
}
|
||||
|
||||
/// There are 4 select variants for each of ABS/NABS (different compare
|
||||
/// constants, compare predicates, select operands). Canonicalize to 1 pattern.
|
||||
/// This makes CSE more likely.
|
||||
static Instruction *canonicalizeAbsNabs(SelectInst &Sel, ICmpInst &Cmp,
|
||||
InstCombiner::BuilderTy &Builder) {
|
||||
if (!Cmp.hasOneUse() || !isa<Constant>(Cmp.getOperand(1)))
|
||||
return nullptr;
|
||||
|
||||
// Choose a sign-bit check for the compare (likely simpler for codegen).
|
||||
// ABS: (X <s 0) ? -X : X
|
||||
// NABS: (X <s 0) ? X : -X
|
||||
Value *LHS, *RHS;
|
||||
SelectPatternFlavor SPF = matchSelectPattern(&Sel, LHS, RHS).Flavor;
|
||||
if (SPF != SelectPatternFlavor::SPF_ABS &&
|
||||
SPF != SelectPatternFlavor::SPF_NABS)
|
||||
return nullptr;
|
||||
|
||||
// Is this already canonical?
|
||||
if (match(Cmp.getOperand(1), m_ZeroInt()) &&
|
||||
Cmp.getPredicate() == ICmpInst::ICMP_SLT)
|
||||
return nullptr;
|
||||
|
||||
// Create the canonical compare.
|
||||
Cmp.setPredicate(ICmpInst::ICMP_SLT);
|
||||
Cmp.setOperand(1, ConstantInt::getNullValue(LHS->getType()));
|
||||
|
||||
// If the select operands do not change, we're done.
|
||||
Value *TVal = Sel.getTrueValue();
|
||||
Value *FVal = Sel.getFalseValue();
|
||||
if (SPF == SelectPatternFlavor::SPF_NABS) {
|
||||
if (TVal == LHS && match(FVal, m_Neg(m_Specific(TVal))))
|
||||
return &Sel;
|
||||
assert(FVal == LHS && match(TVal, m_Neg(m_Specific(FVal))) &&
|
||||
"Unexpected results from matchSelectPattern");
|
||||
} else {
|
||||
if (FVal == LHS && match(TVal, m_Neg(m_Specific(FVal))))
|
||||
return &Sel;
|
||||
assert(TVal == LHS && match(FVal, m_Neg(m_Specific(TVal))) &&
|
||||
"Unexpected results from matchSelectPattern");
|
||||
}
|
||||
|
||||
// We are swapping the select operands, so swap the metadata too.
|
||||
Sel.setTrueValue(FVal);
|
||||
Sel.setFalseValue(TVal);
|
||||
Sel.swapProfMetadata();
|
||||
return &Sel;
|
||||
}
|
||||
|
||||
/// Visit a SelectInst that has an ICmpInst as its first operand.
|
||||
Instruction *InstCombiner::foldSelectInstWithICmp(SelectInst &SI,
|
||||
ICmpInst *ICI) {
|
||||
|
@ -803,6 +851,9 @@ Instruction *InstCombiner::foldSelectInstWithICmp(SelectInst &SI,
|
|||
if (Instruction *NewSel = canonicalizeMinMaxWithConstant(SI, *ICI, Builder))
|
||||
return NewSel;
|
||||
|
||||
if (Instruction *NewAbs = canonicalizeAbsNabs(SI, *ICI, Builder))
|
||||
return NewAbs;
|
||||
|
||||
bool Changed = adjustMinMax(SI, *ICI);
|
||||
|
||||
if (Value *V = foldSelectICmpAnd(SI, ICI, Builder))
|
||||
|
|
|
@ -8,13 +8,13 @@ declare i64 @labs(i64)
|
|||
declare i64 @llabs(i64)
|
||||
|
||||
; Test that the abs library call simplifier works correctly.
|
||||
; abs(x) -> x >s -1 ? x : -x.
|
||||
; abs(x) -> x <s 0 ? -x : x.
|
||||
|
||||
define i32 @test_abs(i32 %x) {
|
||||
; CHECK-LABEL: @test_abs(
|
||||
; CHECK-NEXT: [[ISPOS:%.*]] = icmp sgt i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[ISPOS:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[NEG:%.*]] = sub i32 0, [[X]]
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[ISPOS]], i32 [[X]], i32 [[NEG]]
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[ISPOS]], i32 [[NEG]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[TMP1]]
|
||||
;
|
||||
%ret = call i32 @abs(i32 %x)
|
||||
|
@ -23,9 +23,9 @@ define i32 @test_abs(i32 %x) {
|
|||
|
||||
define i64 @test_labs(i64 %x) {
|
||||
; CHECK-LABEL: @test_labs(
|
||||
; CHECK-NEXT: [[ISPOS:%.*]] = icmp sgt i64 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[ISPOS:%.*]] = icmp slt i64 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[NEG:%.*]] = sub i64 0, [[X]]
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[ISPOS]], i64 [[X]], i64 [[NEG]]
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[ISPOS]], i64 [[NEG]], i64 [[X]]
|
||||
; CHECK-NEXT: ret i64 [[TMP1]]
|
||||
;
|
||||
%ret = call i64 @labs(i64 %x)
|
||||
|
@ -34,22 +34,22 @@ define i64 @test_labs(i64 %x) {
|
|||
|
||||
define i64 @test_llabs(i64 %x) {
|
||||
; CHECK-LABEL: @test_llabs(
|
||||
; CHECK-NEXT: [[ISPOS:%.*]] = icmp sgt i64 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[ISPOS:%.*]] = icmp slt i64 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[NEG:%.*]] = sub i64 0, [[X]]
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[ISPOS]], i64 [[X]], i64 [[NEG]]
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[ISPOS]], i64 [[NEG]], i64 [[X]]
|
||||
; CHECK-NEXT: ret i64 [[TMP1]]
|
||||
;
|
||||
%ret = call i64 @llabs(i64 %x)
|
||||
ret i64 %ret
|
||||
}
|
||||
|
||||
; FIXME: We should have a canonical form of abs to make CSE easier.
|
||||
; We have a canonical form of abs to make CSE easier.
|
||||
|
||||
define i8 @abs_canonical_1(i8 %x) {
|
||||
; CHECK-LABEL: @abs_canonical_1(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[NEG:%.*]] = sub i8 0, [[X]]
|
||||
; CHECK-NEXT: [[ABS:%.*]] = select i1 [[CMP]], i8 [[X]], i8 [[NEG]]
|
||||
; CHECK-NEXT: [[ABS:%.*]] = select i1 [[CMP]], i8 [[NEG]], i8 [[X]]
|
||||
; CHECK-NEXT: ret i8 [[ABS]]
|
||||
;
|
||||
%cmp = icmp sgt i8 %x, 0
|
||||
|
@ -58,13 +58,13 @@ define i8 @abs_canonical_1(i8 %x) {
|
|||
ret i8 %abs
|
||||
}
|
||||
|
||||
; FIXME: Vectors should work too.
|
||||
; Vectors should work too.
|
||||
|
||||
define <2 x i8> @abs_canonical_2(<2 x i8> %x) {
|
||||
; CHECK-LABEL: @abs_canonical_2(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <2 x i8> [[X:%.*]], <i8 -1, i8 -1>
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i8> [[X:%.*]], zeroinitializer
|
||||
; 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: [[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 -1>
|
||||
|
@ -90,7 +90,7 @@ define i8 @abs_canonical_3(i8 %x) {
|
|||
|
||||
define i8 @abs_canonical_4(i8 %x) {
|
||||
; CHECK-LABEL: @abs_canonical_4(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[NEG:%.*]] = sub i8 0, [[X]]
|
||||
; CHECK-NEXT: [[ABS:%.*]] = select i1 [[CMP]], i8 [[NEG]], i8 [[X]]
|
||||
; CHECK-NEXT: ret i8 [[ABS]]
|
||||
|
@ -101,13 +101,13 @@ define i8 @abs_canonical_4(i8 %x) {
|
|||
ret i8 %abs
|
||||
}
|
||||
|
||||
; FIXME: We should have a canonical form of nabs to make CSE easier.
|
||||
; We have a canonical form of nabs to make CSE easier.
|
||||
|
||||
define i8 @nabs_canonical_1(i8 %x) {
|
||||
; CHECK-LABEL: @nabs_canonical_1(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[NEG:%.*]] = sub i8 0, [[X]]
|
||||
; CHECK-NEXT: [[ABS:%.*]] = select i1 [[CMP]], i8 [[NEG]], i8 [[X]]
|
||||
; CHECK-NEXT: [[ABS:%.*]] = select i1 [[CMP]], i8 [[X]], i8 [[NEG]]
|
||||
; CHECK-NEXT: ret i8 [[ABS]]
|
||||
;
|
||||
%cmp = icmp sgt i8 %x, 0
|
||||
|
@ -116,13 +116,13 @@ define i8 @nabs_canonical_1(i8 %x) {
|
|||
ret i8 %abs
|
||||
}
|
||||
|
||||
; FIXME: Vectors should work too.
|
||||
; Vectors should work too.
|
||||
|
||||
define <2 x i8> @nabs_canonical_2(<2 x i8> %x) {
|
||||
; CHECK-LABEL: @nabs_canonical_2(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <2 x i8> [[X:%.*]], <i8 -1, i8 -1>
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i8> [[X:%.*]], zeroinitializer
|
||||
; 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: [[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 -1, i8 -1>
|
||||
|
@ -148,7 +148,7 @@ define i8 @nabs_canonical_3(i8 %x) {
|
|||
|
||||
define i8 @nabs_canonical_4(i8 %x) {
|
||||
; CHECK-LABEL: @nabs_canonical_4(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[NEG:%.*]] = sub i8 0, [[X]]
|
||||
; CHECK-NEXT: [[ABS:%.*]] = select i1 [[CMP]], i8 [[X]], i8 [[NEG]]
|
||||
; CHECK-NEXT: ret i8 [[ABS]]
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
define i32 @abs_abs_x01(i32 %x) {
|
||||
; CHECK-LABEL: @abs_abs_x01(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, -1
|
||||
|
@ -19,9 +19,9 @@ define i32 @abs_abs_x01(i32 %x) {
|
|||
|
||||
define <2 x i32> @abs_abs_x01_vec(<2 x i32> %x) {
|
||||
; CHECK-LABEL: @abs_abs_x01_vec(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <2 x i32> [[X:%.*]], <i32 -1, i32 -1>
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i32> [[X:%.*]], zeroinitializer
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw <2 x i32> zeroinitializer, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select <2 x i1> [[CMP]], <2 x i32> [[X]], <2 x i32> [[SUB]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select <2 x i1> [[CMP]], <2 x i32> [[SUB]], <2 x i32> [[X]]
|
||||
; CHECK-NEXT: ret <2 x i32> [[COND]]
|
||||
;
|
||||
%cmp = icmp sgt <2 x i32> %x, <i32 -1, i32 -1>
|
||||
|
@ -35,9 +35,9 @@ define <2 x i32> @abs_abs_x01_vec(<2 x i32> %x) {
|
|||
|
||||
define i32 @abs_abs_x02(i32 %x) {
|
||||
; CHECK-LABEL: @abs_abs_x02(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, 0
|
||||
|
@ -67,7 +67,7 @@ define i32 @abs_abs_x03(i32 %x) {
|
|||
|
||||
define i32 @abs_abs_x04(i32 %x) {
|
||||
; CHECK-LABEL: @abs_abs_x04(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
|
@ -83,7 +83,7 @@ define i32 @abs_abs_x04(i32 %x) {
|
|||
|
||||
define <2 x i32> @abs_abs_x04_vec(<2 x i32> %x) {
|
||||
; CHECK-LABEL: @abs_abs_x04_vec(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i32> [[X:%.*]], <i32 1, i32 1>
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i32> [[X:%.*]], zeroinitializer
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw <2 x i32> zeroinitializer, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select <2 x i1> [[CMP]], <2 x i32> [[SUB]], <2 x i32> [[X]]
|
||||
; CHECK-NEXT: ret <2 x i32> [[COND]]
|
||||
|
@ -99,9 +99,9 @@ define <2 x i32> @abs_abs_x04_vec(<2 x i32> %x) {
|
|||
|
||||
define i32 @abs_abs_x05(i32 %x) {
|
||||
; CHECK-LABEL: @abs_abs_x05(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, -1
|
||||
|
@ -115,9 +115,9 @@ define i32 @abs_abs_x05(i32 %x) {
|
|||
|
||||
define i32 @abs_abs_x06(i32 %x) {
|
||||
; CHECK-LABEL: @abs_abs_x06(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, 0
|
||||
|
@ -147,7 +147,7 @@ define i32 @abs_abs_x07(i32 %x) {
|
|||
|
||||
define i32 @abs_abs_x08(i32 %x) {
|
||||
; CHECK-LABEL: @abs_abs_x08(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
|
@ -163,9 +163,9 @@ define i32 @abs_abs_x08(i32 %x) {
|
|||
|
||||
define i32 @abs_abs_x09(i32 %x) {
|
||||
; CHECK-LABEL: @abs_abs_x09(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, -1
|
||||
|
@ -179,9 +179,9 @@ define i32 @abs_abs_x09(i32 %x) {
|
|||
|
||||
define i32 @abs_abs_x10(i32 %x) {
|
||||
; CHECK-LABEL: @abs_abs_x10(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, 0
|
||||
|
@ -211,7 +211,7 @@ define i32 @abs_abs_x11(i32 %x) {
|
|||
|
||||
define i32 @abs_abs_x12(i32 %x) {
|
||||
; CHECK-LABEL: @abs_abs_x12(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
|
@ -227,9 +227,9 @@ define i32 @abs_abs_x12(i32 %x) {
|
|||
|
||||
define i32 @abs_abs_x13(i32 %x) {
|
||||
; CHECK-LABEL: @abs_abs_x13(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, -1
|
||||
|
@ -243,9 +243,9 @@ define i32 @abs_abs_x13(i32 %x) {
|
|||
|
||||
define i32 @abs_abs_x14(i32 %x) {
|
||||
; CHECK-LABEL: @abs_abs_x14(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, 0
|
||||
|
@ -275,7 +275,7 @@ define i32 @abs_abs_x15(i32 %x) {
|
|||
|
||||
define i32 @abs_abs_x16(i32 %x) {
|
||||
; CHECK-LABEL: @abs_abs_x16(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
|
@ -291,9 +291,9 @@ define i32 @abs_abs_x16(i32 %x) {
|
|||
|
||||
define i32 @nabs_nabs_x01(i32 %x) {
|
||||
; CHECK-LABEL: @nabs_nabs_x01(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, -1
|
||||
|
@ -307,9 +307,9 @@ define i32 @nabs_nabs_x01(i32 %x) {
|
|||
|
||||
define i32 @nabs_nabs_x02(i32 %x) {
|
||||
; CHECK-LABEL: @nabs_nabs_x02(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, 0
|
||||
|
@ -339,7 +339,7 @@ define i32 @nabs_nabs_x03(i32 %x) {
|
|||
|
||||
define i32 @nabs_nabs_x04(i32 %x) {
|
||||
; CHECK-LABEL: @nabs_nabs_x04(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
|
@ -355,9 +355,9 @@ define i32 @nabs_nabs_x04(i32 %x) {
|
|||
|
||||
define i32 @nabs_nabs_x05(i32 %x) {
|
||||
; CHECK-LABEL: @nabs_nabs_x05(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, -1
|
||||
|
@ -371,9 +371,9 @@ define i32 @nabs_nabs_x05(i32 %x) {
|
|||
|
||||
define i32 @nabs_nabs_x06(i32 %x) {
|
||||
; CHECK-LABEL: @nabs_nabs_x06(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, 0
|
||||
|
@ -403,7 +403,7 @@ define i32 @nabs_nabs_x07(i32 %x) {
|
|||
|
||||
define i32 @nabs_nabs_x08(i32 %x) {
|
||||
; CHECK-LABEL: @nabs_nabs_x08(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
|
@ -419,9 +419,9 @@ define i32 @nabs_nabs_x08(i32 %x) {
|
|||
|
||||
define i32 @nabs_nabs_x09(i32 %x) {
|
||||
; CHECK-LABEL: @nabs_nabs_x09(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, -1
|
||||
|
@ -435,9 +435,9 @@ define i32 @nabs_nabs_x09(i32 %x) {
|
|||
|
||||
define i32 @nabs_nabs_x10(i32 %x) {
|
||||
; CHECK-LABEL: @nabs_nabs_x10(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, 0
|
||||
|
@ -467,7 +467,7 @@ define i32 @nabs_nabs_x11(i32 %x) {
|
|||
|
||||
define i32 @nabs_nabs_x12(i32 %x) {
|
||||
; CHECK-LABEL: @nabs_nabs_x12(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
|
@ -483,9 +483,9 @@ define i32 @nabs_nabs_x12(i32 %x) {
|
|||
|
||||
define i32 @nabs_nabs_x13(i32 %x) {
|
||||
; CHECK-LABEL: @nabs_nabs_x13(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, -1
|
||||
|
@ -499,9 +499,9 @@ define i32 @nabs_nabs_x13(i32 %x) {
|
|||
|
||||
define i32 @nabs_nabs_x14(i32 %x) {
|
||||
; CHECK-LABEL: @nabs_nabs_x14(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, 0
|
||||
|
@ -531,7 +531,7 @@ define i32 @nabs_nabs_x15(i32 %x) {
|
|||
|
||||
define i32 @nabs_nabs_x16(i32 %x) {
|
||||
; CHECK-LABEL: @nabs_nabs_x16(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
|
@ -547,9 +547,9 @@ define i32 @nabs_nabs_x16(i32 %x) {
|
|||
|
||||
define i32 @abs_nabs_x01(i32 %x) {
|
||||
; CHECK-LABEL: @abs_nabs_x01(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, -1
|
||||
|
@ -563,9 +563,9 @@ define i32 @abs_nabs_x01(i32 %x) {
|
|||
|
||||
define i32 @abs_nabs_x02(i32 %x) {
|
||||
; CHECK-LABEL: @abs_nabs_x02(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, 0
|
||||
|
@ -595,7 +595,7 @@ define i32 @abs_nabs_x03(i32 %x) {
|
|||
|
||||
define i32 @abs_nabs_x04(i32 %x) {
|
||||
; CHECK-LABEL: @abs_nabs_x04(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
|
@ -611,9 +611,9 @@ define i32 @abs_nabs_x04(i32 %x) {
|
|||
|
||||
define i32 @abs_nabs_x05(i32 %x) {
|
||||
; CHECK-LABEL: @abs_nabs_x05(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, -1
|
||||
|
@ -627,9 +627,9 @@ define i32 @abs_nabs_x05(i32 %x) {
|
|||
|
||||
define i32 @abs_nabs_x06(i32 %x) {
|
||||
; CHECK-LABEL: @abs_nabs_x06(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, 0
|
||||
|
@ -659,7 +659,7 @@ define i32 @abs_nabs_x07(i32 %x) {
|
|||
|
||||
define i32 @abs_nabs_x08(i32 %x) {
|
||||
; CHECK-LABEL: @abs_nabs_x08(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
|
@ -675,9 +675,9 @@ define i32 @abs_nabs_x08(i32 %x) {
|
|||
|
||||
define i32 @abs_nabs_x09(i32 %x) {
|
||||
; CHECK-LABEL: @abs_nabs_x09(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, -1
|
||||
|
@ -691,9 +691,9 @@ define i32 @abs_nabs_x09(i32 %x) {
|
|||
|
||||
define i32 @abs_nabs_x10(i32 %x) {
|
||||
; CHECK-LABEL: @abs_nabs_x10(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, 0
|
||||
|
@ -723,7 +723,7 @@ define i32 @abs_nabs_x11(i32 %x) {
|
|||
|
||||
define i32 @abs_nabs_x12(i32 %x) {
|
||||
; CHECK-LABEL: @abs_nabs_x12(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
|
@ -739,9 +739,9 @@ define i32 @abs_nabs_x12(i32 %x) {
|
|||
|
||||
define i32 @abs_nabs_x13(i32 %x) {
|
||||
; CHECK-LABEL: @abs_nabs_x13(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, -1
|
||||
|
@ -755,9 +755,9 @@ define i32 @abs_nabs_x13(i32 %x) {
|
|||
|
||||
define i32 @abs_nabs_x14(i32 %x) {
|
||||
; CHECK-LABEL: @abs_nabs_x14(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, 0
|
||||
|
@ -787,7 +787,7 @@ define i32 @abs_nabs_x15(i32 %x) {
|
|||
|
||||
define i32 @abs_nabs_x16(i32 %x) {
|
||||
; CHECK-LABEL: @abs_nabs_x16(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
|
@ -803,9 +803,9 @@ define i32 @abs_nabs_x16(i32 %x) {
|
|||
|
||||
define i32 @nabs_abs_x01(i32 %x) {
|
||||
; CHECK-LABEL: @nabs_abs_x01(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, -1
|
||||
|
@ -819,9 +819,9 @@ define i32 @nabs_abs_x01(i32 %x) {
|
|||
|
||||
define i32 @nabs_abs_x02(i32 %x) {
|
||||
; CHECK-LABEL: @nabs_abs_x02(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, 0
|
||||
|
@ -851,7 +851,7 @@ define i32 @nabs_abs_x03(i32 %x) {
|
|||
|
||||
define i32 @nabs_abs_x04(i32 %x) {
|
||||
; CHECK-LABEL: @nabs_abs_x04(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
|
@ -867,9 +867,9 @@ define i32 @nabs_abs_x04(i32 %x) {
|
|||
|
||||
define i32 @nabs_abs_x05(i32 %x) {
|
||||
; CHECK-LABEL: @nabs_abs_x05(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, -1
|
||||
|
@ -883,9 +883,9 @@ define i32 @nabs_abs_x05(i32 %x) {
|
|||
|
||||
define i32 @nabs_abs_x06(i32 %x) {
|
||||
; CHECK-LABEL: @nabs_abs_x06(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, 0
|
||||
|
@ -915,7 +915,7 @@ define i32 @nabs_abs_x07(i32 %x) {
|
|||
|
||||
define i32 @nabs_abs_x08(i32 %x) {
|
||||
; CHECK-LABEL: @nabs_abs_x08(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
|
@ -931,9 +931,9 @@ define i32 @nabs_abs_x08(i32 %x) {
|
|||
|
||||
define i32 @nabs_abs_x09(i32 %x) {
|
||||
; CHECK-LABEL: @nabs_abs_x09(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, -1
|
||||
|
@ -947,9 +947,9 @@ define i32 @nabs_abs_x09(i32 %x) {
|
|||
|
||||
define i32 @nabs_abs_x10(i32 %x) {
|
||||
; CHECK-LABEL: @nabs_abs_x10(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, 0
|
||||
|
@ -979,7 +979,7 @@ define i32 @nabs_abs_x11(i32 %x) {
|
|||
|
||||
define i32 @nabs_abs_x12(i32 %x) {
|
||||
; CHECK-LABEL: @nabs_abs_x12(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
|
@ -995,9 +995,9 @@ define i32 @nabs_abs_x12(i32 %x) {
|
|||
|
||||
define i32 @nabs_abs_x13(i32 %x) {
|
||||
; CHECK-LABEL: @nabs_abs_x13(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, -1
|
||||
|
@ -1011,9 +1011,9 @@ define i32 @nabs_abs_x13(i32 %x) {
|
|||
|
||||
define i32 @nabs_abs_x14(i32 %x) {
|
||||
; CHECK-LABEL: @nabs_abs_x14(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, 0
|
||||
|
@ -1043,7 +1043,7 @@ define i32 @nabs_abs_x15(i32 %x) {
|
|||
|
||||
define i32 @nabs_abs_x16(i32 %x) {
|
||||
; CHECK-LABEL: @nabs_abs_x16(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
|
|
|
@ -3303,9 +3303,9 @@ define i1 @knownbits8(i8 %a, i8 %b) {
|
|||
define i32 @abs_preserve(i32 %x) {
|
||||
; CHECK-LABEL: @abs_preserve(
|
||||
; CHECK-NEXT: [[A:%.*]] = shl nsw i32 [[X:%.*]], 1
|
||||
; CHECK-NEXT: [[C:%.*]] = icmp sgt i32 [[A]], -1
|
||||
; CHECK-NEXT: [[C:%.*]] = icmp slt i32 [[A]], 0
|
||||
; CHECK-NEXT: [[NEGA:%.*]] = sub i32 0, [[A]]
|
||||
; CHECK-NEXT: [[ABS:%.*]] = select i1 [[C]], i32 [[A]], i32 [[NEGA]]
|
||||
; CHECK-NEXT: [[ABS:%.*]] = select i1 [[C]], i32 [[NEGA]], i32 [[A]]
|
||||
; CHECK-NEXT: ret i32 [[ABS]]
|
||||
;
|
||||
%a = mul nsw i32 %x, 2
|
||||
|
|
|
@ -277,9 +277,9 @@ define i32 @abs_of_min_of_not(i32 %x, i32 %y) {
|
|||
; CHECK-NEXT: [[YADD:%.*]] = add i32 [[Y:%.*]], 2
|
||||
; CHECK-NEXT: [[COND_I:%.*]] = icmp slt i32 [[YADD]], [[XORD]]
|
||||
; CHECK-NEXT: [[MIN:%.*]] = select i1 [[COND_I]], i32 [[YADD]], i32 [[XORD]]
|
||||
; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i32 [[MIN]], -1
|
||||
; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i32 [[MIN]], 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub i32 0, [[MIN]]
|
||||
; CHECK-NEXT: [[ABS:%.*]] = select i1 [[CMP2]], i32 [[MIN]], i32 [[SUB]]
|
||||
; CHECK-NEXT: [[ABS:%.*]] = select i1 [[CMP2]], i32 [[SUB]], i32 [[MIN]]
|
||||
; CHECK-NEXT: ret i32 [[ABS]]
|
||||
;
|
||||
|
||||
|
|
|
@ -104,9 +104,9 @@ define i16 @t7(i32 %a) {
|
|||
|
||||
define i32 @abs_nabs_x01(i32 %x) {
|
||||
; CHECK-LABEL: @abs_nabs_x01(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 %x, -1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 %x, 0
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, %x
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 %x, i32 [[SUB]], !prof ![[$MD1]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 %x, !prof ![[$MD3:[0-9]+]]
|
||||
; CHECK-NEXT: ret i32 [[COND1]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, -1
|
||||
|
@ -118,11 +118,13 @@ define i32 @abs_nabs_x01(i32 %x) {
|
|||
ret i32 %cond18
|
||||
}
|
||||
|
||||
; Swap predicate / metadata order
|
||||
|
||||
define <2 x i32> @abs_nabs_x01_vec(<2 x i32> %x) {
|
||||
; CHECK-LABEL: @abs_nabs_x01_vec(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <2 x i32> %x, <i32 -1, i32 -1>
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i32> %x, zeroinitializer
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub nsw <2 x i32> zeroinitializer, %x
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select <2 x i1> [[CMP]], <2 x i32> %x, <2 x i32> [[SUB]], !prof ![[$MD1]]
|
||||
; CHECK-NEXT: [[COND1:%.*]] = select <2 x i1> [[CMP]], <2 x i32> [[SUB]], <2 x i32> %x, !prof ![[$MD3]]
|
||||
; CHECK-NEXT: ret <2 x i32> [[COND1]]
|
||||
;
|
||||
%cmp = icmp sgt <2 x i32> %x, <i32 -1, i32 -1>
|
||||
|
@ -148,12 +150,11 @@ define i32 @test30(i32 %x, i32 %y) {
|
|||
ret i32 %retval
|
||||
}
|
||||
|
||||
; Swap predicate / metadata order
|
||||
; SMAX(SMAX(X, 75), 36) -> SMAX(X, 75)
|
||||
; SMAX(SMAX(75, X), 36) -> SMAX(X, 75)
|
||||
define i32 @test70(i32 %x) {
|
||||
; CHECK-LABEL: @test70(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i32 %x, 75
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[TMP1]], i32 %x, i32 75, !prof ![[$MD3:[0-9]+]]
|
||||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[TMP1]], i32 %x, i32 75, !prof ![[$MD3]]
|
||||
; CHECK-NEXT: ret i32 [[COND]]
|
||||
;
|
||||
%cmp = icmp slt i32 %x, 75
|
||||
|
|
|
@ -7,9 +7,9 @@ define arm_aapcscc i32 @_abs(i32 %i) nounwind readnone {
|
|||
; CHECK: _abs
|
||||
%call = tail call arm_aapcscc i32 @abs(i32 %i) nounwind readnone
|
||||
ret i32 %call
|
||||
; CHECK: %[[ISPOS:.*]] = icmp sgt i32 %i, -1
|
||||
; CHECK: %[[ISPOS:.*]] = icmp slt i32 %i, 0
|
||||
; CHECK: %[[NEG:.*]] = sub i32 0, %i
|
||||
; CHECK: %[[RET:.*]] = select i1 %[[ISPOS]], i32 %i, i32 %[[NEG]]
|
||||
; CHECK: %[[RET:.*]] = select i1 %[[ISPOS]], i32 %[[NEG]], i32 %i
|
||||
; CHECK: ret i32 %[[RET]]
|
||||
}
|
||||
|
||||
|
@ -19,9 +19,9 @@ define arm_aapcscc i32 @_labs(i32 %i) nounwind readnone {
|
|||
; CHECK: _labs
|
||||
%call = tail call arm_aapcscc i32 @labs(i32 %i) nounwind readnone
|
||||
ret i32 %call
|
||||
; CHECK: %[[ISPOS:.*]] = icmp sgt i32 %i, -1
|
||||
; CHECK: %[[ISPOS:.*]] = icmp slt i32 %i, 0
|
||||
; CHECK: %[[NEG:.*]] = sub i32 0, %i
|
||||
; CHECK: %[[RET:.*]] = select i1 %[[ISPOS]], i32 %i, i32 %[[NEG]]
|
||||
; CHECK: %[[RET:.*]] = select i1 %[[ISPOS]], i32 %[[NEG]], i32 %i
|
||||
; CHECK: ret i32 %[[RET]]
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue