diff --git a/llvm/test/Transforms/InstCombine/wcslen-7.ll b/llvm/test/Transforms/InstCombine/wcslen-7.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Transforms/InstCombine/wcslen-7.ll @@ -0,0 +1,23 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; +; RUN: opt < %s -passes=instcombine -S | FileCheck %s + +declare i64 @wcslen(ptr) + +!0 = !{i32 1, !"wchar_size", i32 4} +!llvm.module.flags = !{!0} + +@ws = constant [10 x i32] [i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0] + + +; Fold wcslen(ws + 2) => 7. +; FIXME: This fold is faulty, result should be 7 not 1. +define dso_local i64 @fold_wcslen_1() { +; CHECK-LABEL: @fold_wcslen_1( +; CHECK-NEXT: ret i64 1 +; + %ps3_pi = getelementptr inbounds [10 x i32], ptr @ws, i64 0, i64 2 + %len = tail call i64 @wcslen(ptr %ps3_pi) + ret i64 %len +} +