diff --git a/llvm/include/llvm/Analysis/ValueLattice.h b/llvm/include/llvm/Analysis/ValueLattice.h --- a/llvm/include/llvm/Analysis/ValueLattice.h +++ b/llvm/include/llvm/Analysis/ValueLattice.h @@ -352,17 +352,17 @@ if (getConstantRange() == NewR) return Tag != OldTag; - // Simple form of widening. If a range is extended multiple times, use the - // provided WidenCR upper bound if it contains NewR or overdefined + // Simple form of widening. If a range is extended more than twice, use + // the provided WidenCR upper bound if it contains NewR or overdefined // otherwise. - if (Opts.CheckWiden && ++NumRangeExtensions >= 1) { + if (Opts.CheckWiden && ++NumRangeExtensions >= 2) { // Make sure WidenCR is only used if it contains the merge result. if (!Opts.WidenCR.isFullSet() && (NewR == Opts.WidenCR || Opts.WidenCR.contains(NewR))) { assert(NewR.contains(getConstantRange())); bool Changed = Opts.WidenCR != getConstantRange(); Range = std::move(Opts.WidenCR); - NumRangeExtensions = 1; + NumRangeExtensions = 2; return Changed || Tag != OldTag; } return markOverdefined(); diff --git a/llvm/test/Transforms/SCCP/constant-range-struct.ll b/llvm/test/Transforms/SCCP/constant-range-struct.ll --- a/llvm/test/Transforms/SCCP/constant-range-struct.ll +++ b/llvm/test/Transforms/SCCP/constant-range-struct.ll @@ -102,18 +102,14 @@ ; CHECK-NEXT: [[S:%.*]] = call { i64, i64 } @struct2() ; CHECK-NEXT: [[V1:%.*]] = extractvalue { i64, i64 } [[S]], 0 ; CHECK-NEXT: [[V2:%.*]] = extractvalue { i64, i64 } [[S]], 1 -; CHECK-NEXT: [[T_1:%.*]] = icmp ne i64 [[V1]], 10 -; CHECK-NEXT: call void @use(i1 [[T_1]]) -; CHECK-NEXT: [[T_2:%.*]] = icmp ult i64 [[V1]], 100 -; CHECK-NEXT: call void @use(i1 [[T_2]]) +; CHECK-NEXT: call void @use(i1 true) +; CHECK-NEXT: call void @use(i1 true) ; CHECK-NEXT: [[T_3:%.*]] = icmp ne i64 [[V2]], 0 ; CHECK-NEXT: call void @use(i1 [[T_3]]) ; CHECK-NEXT: [[T_4:%.*]] = icmp ult i64 [[V2]], 301 ; CHECK-NEXT: call void @use(i1 [[T_4]]) -; CHECK-NEXT: [[F_1:%.*]] = icmp eq i64 [[V1]], 10 -; CHECK-NEXT: call void @use(i1 [[F_1]]) -; CHECK-NEXT: [[F_2:%.*]] = icmp ult i64 [[V1]], 19 -; CHECK-NEXT: call void @use(i1 [[F_2]]) +; CHECK-NEXT: call void @use(i1 false) +; CHECK-NEXT: call void @use(i1 false) ; CHECK-NEXT: [[F_3:%.*]] = icmp eq i64 [[V2]], 50 ; CHECK-NEXT: call void @use(i1 [[F_3]]) ; CHECK-NEXT: [[F_4:%.*]] = icmp ugt i64 [[V2]], 301 diff --git a/llvm/test/Transforms/SCCP/widening.ll b/llvm/test/Transforms/SCCP/widening.ll --- a/llvm/test/Transforms/SCCP/widening.ll +++ b/llvm/test/Transforms/SCCP/widening.ll @@ -17,10 +17,8 @@ ; SCCP: exit: ; SCCP-NEXT: [[P:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ 1, [[BB1]] ] ; SCCP-NEXT: [[A:%.*]] = add i32 [[P]], 1 -; SCCP-NEXT: [[T_1:%.*]] = icmp ult i32 [[A]], 20 -; SCCP-NEXT: call void @use(i1 [[T_1]]) -; SCCP-NEXT: [[F_1:%.*]] = icmp ugt i32 [[A]], 10 -; SCCP-NEXT: call void @use(i1 [[F_1]]) +; SCCP-NEXT: call void @use(i1 true) +; SCCP-NEXT: call void @use(i1 false) ; SCCP-NEXT: ret void ; ; IPSCCP-LABEL: @test_2_incoming_constants( @@ -32,10 +30,8 @@ ; IPSCCP: exit: ; IPSCCP-NEXT: [[P:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ 1, [[BB1]] ] ; IPSCCP-NEXT: [[A:%.*]] = add i32 [[P]], 1 -; IPSCCP-NEXT: [[T_1:%.*]] = icmp ult i32 [[A]], 20 -; IPSCCP-NEXT: call void @use(i1 [[T_1]]) -; IPSCCP-NEXT: [[F_1:%.*]] = icmp ugt i32 [[A]], 10 -; IPSCCP-NEXT: call void @use(i1 [[F_1]]) +; IPSCCP-NEXT: call void @use(i1 true) +; IPSCCP-NEXT: call void @use(i1 false) ; IPSCCP-NEXT: ret void ; entry: @@ -68,10 +64,8 @@ ; SCCP: exit: ; SCCP-NEXT: [[P:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ 1, [[BB1]] ], [ 2, [[BB2]] ] ; SCCP-NEXT: [[A:%.*]] = add i32 [[P]], 1 -; SCCP-NEXT: [[T_1:%.*]] = icmp ult i32 [[A]], 20 -; SCCP-NEXT: call void @use(i1 [[T_1]]) -; SCCP-NEXT: [[F_1:%.*]] = icmp ugt i32 [[A]], 10 -; SCCP-NEXT: call void @use(i1 [[F_1]]) +; SCCP-NEXT: call void @use(i1 true) +; SCCP-NEXT: call void @use(i1 false) ; SCCP-NEXT: ret void ; ; IPSCCP-LABEL: @test_3_incoming_constants( @@ -86,10 +80,8 @@ ; IPSCCP: exit: ; IPSCCP-NEXT: [[P:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ 1, [[BB1]] ], [ 2, [[BB2]] ] ; IPSCCP-NEXT: [[A:%.*]] = add i32 [[P]], 1 -; IPSCCP-NEXT: [[T_1:%.*]] = icmp ult i32 [[A]], 20 -; IPSCCP-NEXT: call void @use(i1 [[T_1]]) -; IPSCCP-NEXT: [[F_1:%.*]] = icmp ugt i32 [[A]], 10 -; IPSCCP-NEXT: call void @use(i1 [[F_1]]) +; IPSCCP-NEXT: call void @use(i1 true) +; IPSCCP-NEXT: call void @use(i1 false) ; IPSCCP-NEXT: ret void ; entry: @@ -132,10 +124,8 @@ ; SCCP: exit: ; SCCP-NEXT: [[P:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ 1, [[BB1]] ], [ 2, [[BB2]] ], [ 3, [[BB3]] ], [ 4, [[BB4]] ] ; SCCP-NEXT: [[A:%.*]] = add i32 [[P]], 1 -; SCCP-NEXT: [[T_1:%.*]] = icmp ult i32 [[A]], 20 -; SCCP-NEXT: call void @use(i1 [[T_1]]) -; SCCP-NEXT: [[F_1:%.*]] = icmp ugt i32 [[A]], 10 -; SCCP-NEXT: call void @use(i1 [[F_1]]) +; SCCP-NEXT: call void @use(i1 true) +; SCCP-NEXT: call void @use(i1 false) ; SCCP-NEXT: ret void ; ; IPSCCP-LABEL: @test_5_incoming_constants( @@ -156,10 +146,8 @@ ; IPSCCP: exit: ; IPSCCP-NEXT: [[P:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ 1, [[BB1]] ], [ 2, [[BB2]] ], [ 3, [[BB3]] ], [ 4, [[BB4]] ] ; IPSCCP-NEXT: [[A:%.*]] = add i32 [[P]], 1 -; IPSCCP-NEXT: [[T_1:%.*]] = icmp ult i32 [[A]], 20 -; IPSCCP-NEXT: call void @use(i1 [[T_1]]) -; IPSCCP-NEXT: [[F_1:%.*]] = icmp ugt i32 [[A]], 10 -; IPSCCP-NEXT: call void @use(i1 [[F_1]]) +; IPSCCP-NEXT: call void @use(i1 true) +; IPSCCP-NEXT: call void @use(i1 false) ; IPSCCP-NEXT: ret void ; entry: