llvm/llvm/test/Transforms/GVN/noundef.ll

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -passes=gvn -S %s | FileCheck %s
;
;Check that !noundef metadata is combined.
define i32 @one_noundef(ptr %p) {
; CHECK-LABEL: @one_noundef(
; CHECK-NEXT:    [[A:%.*]] = load i32, ptr [[P:%.*]], align 4, !noundef !0
; CHECK-NEXT:    [[C:%.*]] = add i32 [[A]], [[A]]
; CHECK-NEXT:    ret i32 [[C]]
;
  %a = load i32, ptr %p, !noundef !0
  %b = load i32, ptr %p
  %c = add i32 %a, %b
  ret i32 %c
}

define i32 @both_noundef(ptr %p) {
; CHECK-LABEL: @both_noundef(
; CHECK-NEXT:    [[A:%.*]] = load i32, ptr [[P:%.*]], align 4, !noundef !0
; CHECK-NEXT:    [[C:%.*]] = add i32 [[A]], [[A]]
; CHECK-NEXT:    ret i32 [[C]]
;
  %a = load i32, ptr %p, !noundef !0
  %b = load i32, ptr %p, !noundef !0
  %c = add i32 %a, %b
  ret i32 %c
}
!0 = !{}