[PATCH] D136201: [InstCombine] Handle PHI nodes in PtrReplacer
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 16 01:17:46 PST 2023
nikic added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:68
auto *I = cast<Instruction>(U.getUser());
-
if (auto *LI = dyn_cast<LoadInst>(I)) {
----------------
Spurious change.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:307-313
+ if (any_of(PHI->incoming_values(), [this, Inst](Value *V) {
+ if (!Worklist.contains(cast<Instruction>(V))) {
+ ValuesToRevisit.insert(Inst);
+ return true;
+ }
+ return false;
+ }))
----------------
The ValuesToRevisit update should happen outside the any_of.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:458
eraseInstFromFunction(*Delete);
-
Value *Cast = Builder.CreateBitCast(TheSrc, DestTy);
----------------
Spurious change.
================
Comment at: llvm/test/Transforms/InstCombine/replace-alloca-phi.ll:11
; CHECK-LABEL: @remove_alloca_use_arg(
-; CHECK-NEXT: entry:
-; CHECK-NEXT: [[ALLOCA:%.*]] = alloca [32 x i8], align 4, addrspace(1)
-; CHECK-NEXT: call void @llvm.memcpy.p1.p0.i64(ptr addrspace(1) noundef align 4 dereferenceable(256) [[ALLOCA]], ptr noundef nonnull align 16 dereferenceable(256) @g1, i64 256, i1 false)
-; CHECK-NEXT: br i1 [[COND:%.*]], label [[IF:%.*]], label [[ELSE:%.*]]
-; CHECK: if:
-; CHECK-NEXT: [[VAL_IF:%.*]] = getelementptr inbounds [32 x i8], ptr addrspace(1) [[ALLOCA]], i64 0, i64 2
-; CHECK-NEXT: br label [[SINK:%.*]]
-; CHECK: else:
-; CHECK-NEXT: [[VAL_ELSE:%.*]] = getelementptr inbounds [32 x i8], ptr addrspace(1) [[ALLOCA]], i64 0, i64 1
-; CHECK-NEXT: br label [[SINK]]
-; CHECK: sink:
-; CHECK-NEXT: [[PTR:%.*]] = phi ptr addrspace(1) [ [[VAL_IF]], [[IF]] ], [ [[VAL_ELSE]], [[ELSE]] ]
-; CHECK-NEXT: [[LOAD:%.*]] = load i8, ptr addrspace(1) [[PTR]], align 1
-; CHECK-NEXT: ret i8 [[LOAD]]
+; CHECk-NEXT: entry:
+; CHECk-NEXT: br i1 [[COND:%.*]], label [[IF:%.*]], label [[ELSE:%.*]]
----------------
Broken check line (should be `CHECK`).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136201/new/
https://reviews.llvm.org/D136201
More information about the llvm-commits
mailing list