[llvm] [InstCombinePHI] Enhance PHI CSE to remove redundant phis (PR #163453)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 21 20:03:22 PDT 2025
dtcxzyw wrote:
> target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
> target triple = "x86_64-unknown-fuchsia"
>
> define i8 @f(ptr %__p, i1 %0) {
> entry:
> br label %for.cond
>
> for.cond: ; preds = %for.inc, %entry
> %__p.pn = phi ptr [ %__p, %entry ], [ %__p.addr.0, %for.inc ]
> %__p.addr.0 = getelementptr i8, ptr %__p.pn, i64 1
> br i1 false, label %cleanup17, label %for.body
>
> for.body: ; preds = %for.cond
> %1 = load i8, ptr %__p.pn, align 1
> br i1 false, label %for.inc, label %if.else
>
> if.else: ; preds = %for.body
> %incdec.ptr11 = getelementptr i8, ptr %__p.pn, i64 2
> %spec.select = select i1 %0, ptr %__p.addr.0, ptr %incdec.ptr11
> br label %cleanup17
>
> for.inc: ; preds = %for.body
> br label %for.cond
>
> cleanup17: ; preds = %if.else, %for.cond
> %__p.addr.3 = phi ptr [ %spec.select, %if.else ], [ %__p.addr.0, %for.cond ]
> %2 = load i8, ptr %__p.addr.3, align 1
> ret i8 %2
> }
> PN = %lsr.iv = phi ptr [ %scevgep1, %for.inc ], [ %scevgep, %entry ]
IdenticalPN = %sunk_phi5 = phi ptr
It is caused by CGP:AddressingModeMatcher. It calls simplifyInstruction before filling the incoming values of new PHI nodes.
I will post a fix tonight (UTC+8).
https://github.com/llvm/llvm-project/pull/163453
More information about the llvm-commits
mailing list