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
4 changes: 3 additions & 1 deletion llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,10 @@ struct ConstantComparesGatherer {
return false;

// Add all values from the range to the set
for (APInt Tmp = Span.getLower(); Tmp != Span.getUpper(); ++Tmp)
APInt Tmp = Span.getLower();
do
Vals.push_back(ConstantInt::get(I->getContext(), Tmp));
while (++Tmp != Span.getUpper());

UsedICmps++;
return true;
Expand Down
37 changes: 37 additions & 0 deletions llvm/test/Transforms/SimplifyCFG/pr166369.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
; RUN: opt -S -passes=simplifycfg < %s | FileCheck %s

; Make sure we handle full-set ranges correctly.
define void @test_i1() {
; CHECK-LABEL: define void @test_i1() {
; CHECK-NEXT: [[BB:.*:]]
; CHECK-NEXT: ret void
;
bb:
%icmp = icmp ugt i1 false, true
br label %bb5

bb5:
%select = select i1 %icmp, i1 %icmp, i1 false
br i1 %select, label %bb5, label %bb6

bb6:
ret void
}

define void @test_i3() {
; CHECK-LABEL: define void @test_i3() {
; CHECK-NEXT: [[BB:.*:]]
; CHECK-NEXT: ret void
;
bb:
%icmp = icmp ugt i3 0, 7
br label %bb5

bb5:
%select = select i1 %icmp, i1 %icmp, i1 false
br i1 %select, label %bb5, label %bb6

bb6:
ret void
}