[llvm] [InstCombine] Fold `(icmp pred (trunc nuw/nsw X), C)` -> `(icmp pred X, (zext/sext C))` (PR #87935)

via llvm-commits llvm-commits at lists.llvm.org
Thu May 2 12:05:54 PDT 2024


================
@@ -555,3 +555,147 @@ define i1 @shl1_trunc_sgt4(i32 %a) {
   %r = icmp sgt i16 %t, 4
   ret i1 %r
 }
+
+define i1 @eq_nuw(i32 %x) {
+; DL64-LABEL: @eq_nuw(
+; DL64-NEXT:    [[TMP1:%.*]] = and i32 [[X:%.*]], 255
+; DL64-NEXT:    [[R:%.*]] = icmp eq i32 [[TMP1]], 123
+; DL64-NEXT:    ret i1 [[R]]
----------------
goldsteinn wrote:

In this case b.c the `foldICmp*Constant` expect the constant to be an `APInt`, but this fold doesn't change w/ or w.o splat argument...
ill move it to `foldICmpTruncConstant` though as any other solution seems like more work that supporting non-splats is worth.

https://github.com/llvm/llvm-project/pull/87935


More information about the llvm-commits mailing list