From ff477f8594e9ccd42c28e8e181785331e94c8719 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 12 Dec 2004 05:52:12 +0000 Subject: [PATCH] New testcase. Shrinking the variable to a bool allows instcombine to delete the condition. llvm-svn: 18816 --- .../Transforms/GlobalOpt/integer-bool.ll | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 test/Regression/Transforms/GlobalOpt/integer-bool.ll diff --git a/test/Regression/Transforms/GlobalOpt/integer-bool.ll b/test/Regression/Transforms/GlobalOpt/integer-bool.ll new file mode 100644 index 00000000000..2daf9550f6e --- /dev/null +++ b/test/Regression/Transforms/GlobalOpt/integer-bool.ll @@ -0,0 +1,22 @@ +; RUN: llvm-as < %s | opt -globalopt -instcombine | llvm-dis | grep 'ret bool true' + +;; check that global opt turns integers that only hold 0 or 1 into bools. + +%G = internal global int 0 ;; This only holds 0 or 1. + +implementation + +void %set1() { + store int 0, int* %G + ret void +} +void %set2() { + store int 1, int* %G + ret void +} + +bool %get() { + %A = load int* %G + %C = setlt int %A, 2 ;; always true + ret bool %C +}