From 14c0987bd9ab50ebb8728e62a0b29d8f7f951984 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer <benny.kra@googlemail.com> Date: Fri, 17 Dec 2010 10:48:14 +0000 Subject: [PATCH] SimplifyCFG: Ranges can be larger than 64 bits. Fixes Release-selfhost build. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122054 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Utils/SimplifyCFG.cpp | 2 +- test/Transforms/SimplifyCFG/switch_create.ll | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index 9bb61b6041ce..1eb8e8eecfb1 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -324,7 +324,7 @@ GatherConstantCompares(Value *V, std::vector<ConstantInt*> &Vals, Value *&Extra, Span = Span.inverse(); // If there are a ton of values, we don't want to make a ginormous switch. - if (Span.getSetSize().getZExtValue() > 8 || Span.isEmptySet() || + if (Span.getSetSize().ugt(8) || Span.isEmptySet() || // We don't handle wrapped sets yet. Span.isWrappedSet()) return 0; diff --git a/test/Transforms/SimplifyCFG/switch_create.ll b/test/Transforms/SimplifyCFG/switch_create.ll index 369ebc352725..da7f65a6ca35 100644 --- a/test/Transforms/SimplifyCFG/switch_create.ll +++ b/test/Transforms/SimplifyCFG/switch_create.ll @@ -421,3 +421,23 @@ if.end: ; preds = %if.then, %lor.lhs.f ; CHECK: ] } +; Don't crash on ginormous ranges. +define void @test15(i128 %x) nounwind { + %cmp = icmp ugt i128 %x, 2 + br i1 %cmp, label %if.end, label %lor.false + +lor.false: + %cmp2 = icmp ne i128 %x, 100000000000000000000 + br i1 %cmp2, label %if.end, label %if.then + +if.then: + call void @foo1() noredzone + br label %if.end + +if.end: + ret void + +; CHECK: @test15 +; CHECK-NOT: switch +; CHECK: ret void +} -- GitLab