xref: /llvm-project/llvm/test/Transforms/GVN/noundef.ll (revision 232698dc171ed7e3639db4a18e6d1abfba89f68b)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -passes=gvn -S %s | FileCheck %s
3;
4;Check that !noundef metadata is combined.
5define i32 @one_noundef(ptr %p) {
6; CHECK-LABEL: @one_noundef(
7; CHECK-NEXT:    [[A:%.*]] = load i32, ptr [[P:%.*]], align 4, !noundef !0
8; CHECK-NEXT:    [[C:%.*]] = add i32 [[A]], [[A]]
9; CHECK-NEXT:    ret i32 [[C]]
10;
11  %a = load i32, ptr %p, !noundef !0
12  %b = load i32, ptr %p
13  %c = add i32 %a, %b
14  ret i32 %c
15}
16
17define i32 @both_noundef(ptr %p) {
18; CHECK-LABEL: @both_noundef(
19; CHECK-NEXT:    [[A:%.*]] = load i32, ptr [[P:%.*]], align 4, !noundef !0
20; CHECK-NEXT:    [[C:%.*]] = add i32 [[A]], [[A]]
21; CHECK-NEXT:    ret i32 [[C]]
22;
23  %a = load i32, ptr %p, !noundef !0
24  %b = load i32, ptr %p, !noundef !0
25  %c = add i32 %a, %b
26  ret i32 %c
27}
28!0 = !{}
29