[PATCH] D156657: [InstCombine] 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 09:46:34 PDT 2023


XChy added a comment.

In D156657#4547304 <https://reviews.llvm.org/D156657#4547304>, @nikic wrote:

> It would be better to base this on collectOffset() and work in offset representation. Especially if you're interested in handling Rust, the type of the global and the GEP / loads will typically not line up (constant globals in Rust are usually i8 arrays, regardless of "real" type.)

Yes, such generlization in units of byte is necessary. It seems to be related to ptradd RFC?
Currently, this fold is still in units of array element . I'll try to refactor and generlize it.



================
Comment at: llvm/test/Transforms/InstCombine/load-cmp.ll:349
+; CHECK-NEXT:    [[TMP0:%.*]] = and i64 [[X]], 4294967294
+; CHECK-NEXT:    [[COND_INFERRED:%.*]] = icmp eq i64 [[TMP0]], 0
 ; CHECK-NEXT:    ret i1 [[COND_INFERRED]]
----------------
Optimized well locally, but not globally.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156657/new/

https://reviews.llvm.org/D156657



More information about the llvm-commits mailing list