[llvm] [InstCombine] Fold `(trunc X)` into `X & Mask` inside `decomposeBitTestICmp` (PR #171195)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 12 08:11:49 PST 2025


================
@@ -314,15 +314,10 @@ define i1 @sgt_n1_use(i32 %x) {
 }
 
 define i1 @trunc_eq_i32_i8(i32 %x) {
-; DL64-LABEL: @trunc_eq_i32_i8(
-; DL64-NEXT:    [[TMP1:%.*]] = and i32 [[X:%.*]], 255
-; DL64-NEXT:    [[R:%.*]] = icmp eq i32 [[TMP1]], 42
-; DL64-NEXT:    ret i1 [[R]]
-;
-; DL8-LABEL: @trunc_eq_i32_i8(
-; DL8-NEXT:    [[T:%.*]] = trunc i32 [[X:%.*]] to i8
-; DL8-NEXT:    [[R:%.*]] = icmp eq i8 [[T]], 42
-; DL8-NEXT:    ret i1 [[R]]
+; CHECK-LABEL: @trunc_eq_i32_i8(
----------------
dtcxzyw wrote:

Missing `shouldChangeType` here:
https://github.com/llvm/llvm-project/blob/d7cbc7f9e465344dd326eaf6e5a6cfa90285ce8e/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp#L6291-L6298

See also https://github.com/llvm/llvm-project/commit/cc88445a9106333bad7679f72031b5602b3a2953

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


More information about the llvm-commits mailing list