diff options
| author | Nick Lewycky <nicholas@mxc.ca> | 2014-05-02 04:11:45 +0000 |
|---|---|---|
| committer | Nick Lewycky <nicholas@mxc.ca> | 2014-05-02 04:11:45 +0000 |
| commit | 718ada97bcd0007dcb9c6a0ea86e4be88c9d4b6b (patch) | |
| tree | e2fcbb2a51664414e15a993a608c6d7d25192e92 /llvm/test | |
| parent | 0e363b75a4dbfe1f48fb0c0f9866a0a0027d1374 (diff) | |
| download | bcm5719-llvm-718ada97bcd0007dcb9c6a0ea86e4be88c9d4b6b.tar.gz bcm5719-llvm-718ada97bcd0007dcb9c6a0ea86e4be88c9d4b6b.zip | |
Fold strlen(expr ? "str1" : "str2") to x ? len1 : len2. This fires about 330 times in a bootstrap of clang.
llvm-svn: 207828
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/strlen-1.ll | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/strlen-1.ll b/llvm/test/Transforms/InstCombine/strlen-1.ll index 4fa5b4fdb62..4a3caf28a0f 100644 --- a/llvm/test/Transforms/InstCombine/strlen-1.ll +++ b/llvm/test/Transforms/InstCombine/strlen-1.ll @@ -5,6 +5,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" @hello = constant [6 x i8] c"hello\00" +@longer = constant [7 x i8] c"longer\00" @null = constant [1 x i8] zeroinitializer @null_hello = constant [7 x i8] c"\00hello\00" @nullstring = constant i8 0 @@ -85,6 +86,17 @@ define i1 @test_simplify8() { ; CHECK-NEXT: ret i1 false } +define i32 @test_simplify9(i1 %x) { +; CHECK-LABEL: @test_simplify9 + %hello = getelementptr [6 x i8]* @hello, i32 0, i32 0 + %longer = getelementptr [7 x i8]* @longer, i32 0, i32 0 + %s = select i1 %x, i8* %hello, i8* %longer + %l = call i32 @strlen(i8* %s) +; CHECK-NEXT: select i1 %x, i32 5, i32 6 + ret i32 %l +; CHECK-NEXT: ret +} + ; Check cases that shouldn't be simplified. define i32 @test_no_simplify1() { |

