From 279ff0f8ee19aeb2c71a1dc27e1b798da73963b0 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 4 Oct 2022 15:09:04 +0200 Subject: [PATCH] [InstCombine] Add test where op of phi simplifies to phi (NFC) Degenerate case for D134954. --- llvm/test/Transforms/InstCombine/phi.ll | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/llvm/test/Transforms/InstCombine/phi.ll b/llvm/test/Transforms/InstCombine/phi.ll index df5e174..dac6eb3 100644 --- a/llvm/test/Transforms/InstCombine/phi.ll +++ b/llvm/test/Transforms/InstCombine/phi.ll @@ -1315,3 +1315,27 @@ exit: %res = phi i1 [ true, %start ], [ %and, %loop ] ret i1 %res } + +declare void @use(i32) + +define i32 @phi_op_self_simplify() { +; CHECK-LABEL: @phi_op_self_simplify( +; CHECK-NEXT: entry: +; CHECK-NEXT: br label [[LOOP:%.*]] +; CHECK: loop: +; CHECK-NEXT: [[IV:%.*]] = phi i32 [ 1, [[ENTRY:%.*]] ], [ [[IV_ADD2:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[IV_ADD:%.*]] = xor i32 [[IV]], -1 +; CHECK-NEXT: call void @use(i32 [[IV_ADD]]) +; CHECK-NEXT: [[IV_ADD2]] = xor i32 [[IV]], -1 +; CHECK-NEXT: br label [[LOOP]] +; +entry: + br label %loop + +loop: + %iv = phi i32 [ 1, %entry ], [ %iv.add2, %loop ] + %iv.add = xor i32 %iv, -1 + call void @use(i32 %iv.add) + %iv.add2 = xor i32 %iv, -1 + br label %loop +} -- 2.7.4