[PATCH] D156657: [ValueTracking][NFC] Fold icmp(constants[x]) when the range of x is given
Hongyu Chen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 31 02:25:02 PDT 2023
XChy created this revision.
XChy added reviewers: nikic, goldstein.w.n.
Herald added subscribers: StephenFan, arphaman, hiraditya.
Herald added a project: All.
XChy requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This patch extends **isImpliedCondICmps** to fold IR below:
define i1 @cmp_load_constant_array0(i64 %x){
entry:
%cond = icmp ult i64 %x, 2
br i1 %cond, label %case1, label %case2
case2:
ret i1 0
case1:
%isOK_ptr = getelementptr inbounds i32, ptr @CG, i64 %x
%isOK = load i32, ptr %isOK_ptr
%cond_inferred = icmp ult i32 %isOK, 3
ret i1 %cond_inferred
}
If D152838 <https://reviews.llvm.org/D152838> is accepted, that would be better for complex situation
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D156657
Files:
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/InstCombine/load-cmp-index.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156657.545549.patch
Type: text/x-patch
Size: 4361 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230731/11edd36b/attachment.bin>
More information about the llvm-commits
mailing list