mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
InstCombine: Turn (x != 0 & x <u C) into the canonical range check form (x-1 <u C-1)
llvm-svn: 219585
This commit is contained in:
parent
3b8f17ae65
commit
8581af15aa
@ -930,6 +930,8 @@ Value *InstCombiner::FoldAndOfICmps(ICmpInst *LHS, ICmpInst *RHS) {
|
||||
case ICmpInst::ICMP_ULT:
|
||||
if (LHSCst == SubOne(RHSCst)) // (X != 13 & X u< 14) -> X < 13
|
||||
return Builder->CreateICmpULT(Val, LHSCst);
|
||||
if (LHSCst->isNullValue()) // (X != 0 & X u< 14) -> X-1 u< 13
|
||||
return InsertRangeTest(Val, AddOne(LHSCst), RHSCst, false, true);
|
||||
break; // (X != 13 & X u< 15) -> no change
|
||||
case ICmpInst::ICMP_SLT:
|
||||
if (LHSCst == SubOne(RHSCst)) // (X != 13 & X s< 14) -> X < 13
|
||||
|
@ -66,3 +66,14 @@ define i1 @test7(i32 %i, i1 %b) {
|
||||
%and2 = and i1 %and1, %cmp2
|
||||
ret i1 %and2
|
||||
}
|
||||
|
||||
define i1 @test8(i32 %i) {
|
||||
; CHECK-LABEL: @test8(
|
||||
; CHECK-NEXT: [[DEC:%.*]] = add i32 %i, -1
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[DEC]], 13
|
||||
; CHECK-NEXT: ret i1 [[CMP]]
|
||||
%cmp1 = icmp ne i32 %i, 0
|
||||
%cmp2 = icmp ult i32 %i, 14
|
||||
%cond = and i1 %cmp1, %cmp2
|
||||
ret i1 %cond
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user