Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions llvm/lib/IR/Operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ bool Operator::hasPoisonGeneratingFlags() const {
if (auto *NNI = dyn_cast<PossiblyNonNegInst>(this))
return NNI->hasNonNeg();
return false;
case Instruction::ICmp:
return cast<ICmpInst>(this)->hasSameSign();
default:
if (const auto *FP = dyn_cast<FPMathOperator>(this))
return FP->hasNoNaNs() || FP->hasNoInfs();
Expand Down
22 changes: 22 additions & 0 deletions llvm/test/Transforms/InstCombine/icmp.ll
Original file line number Diff line number Diff line change
Expand Up @@ -5365,3 +5365,25 @@ define i1 @icmp_and_inv_pow2_or_zero_ne_0(i32 %A, i32 %B) {
%cmp = icmp ne i32 %and, 0
ret i1 %cmp
}

define i1 @icmp_samesign_logical_and(i32 %In) {
; CHECK-LABEL: @icmp_samesign_logical_and(
; CHECK-NEXT: [[C2:%.*]] = icmp eq i32 [[IN:%.*]], 1
; CHECK-NEXT: ret i1 [[C2]]
;
%c1 = icmp samesign sgt i32 %In, -1
%c2 = icmp samesign eq i32 %In, 1
%V = select i1 %c1, i1 %c2, i1 false
ret i1 %V
}

define i1 @icmp_samesign_logical_or(i32 %In) {
; CHECK-LABEL: @icmp_samesign_logical_or(
; CHECK-NEXT: [[V:%.*]] = icmp ne i32 [[IN:%.*]], 1
; CHECK-NEXT: ret i1 [[V]]
;
%c1 = icmp samesign slt i32 %In, 0
%c2 = icmp samesign ne i32 %In, 1
%V = select i1 %c1, i1 true, i1 %c2
ret i1 %V
}
Loading