xref: /llvm-project/llvm/test/Transforms/SCCP/remove-call-inst.ll (revision 16bb8c16aab32e2ee623a2b64d976548be247180)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -S -passes=ipsccp | FileCheck %s
3; PR5596
4
5; IPSCCP should propagate the 0 argument, eliminate the switch, and propagate
6; the result.
7
8define i32 @main() noreturn nounwind {
9; CHECK-LABEL: @main(
10; CHECK-NEXT:  entry:
11; CHECK-NEXT:    ret i32 123
12;
13entry:
14  %call2 = tail call i32 @wwrite(i64 0) nounwind
15  ret i32 %call2
16}
17
18define internal i32 @wwrite(i64 %i) nounwind readnone willreturn {
19; CHECK-LABEL: @wwrite(
20; CHECK-NEXT:  entry:
21; CHECK-NEXT:    br label [[SW_DEFAULT:%.*]]
22; CHECK:       sw.default:
23; CHECK-NEXT:    ret i32 poison
24;
25entry:
26  switch i64 %i, label %sw.default [
27  i64 3, label %return
28  i64 10, label %return
29  ]
30
31sw.default:
32  ret i32 123
33
34return:
35  ret i32 0
36}
37
38; CHECK: attributes #0 = { noreturn nounwind }
39; CHECK: attributes #1 = { nounwind willreturn memory(none) }
40