Issue 183584
Summary [InstCombine] Discuss generalizing icmp eq/ne X, 0 to trunc X to i1 using KnownBits
Labels new issue
Assignees
Reporter ParkHanbum
    1. Previous State
InstCombine currently folds icmp ne (and X, 1), 0 to trunc X to i1 using strict syntactic pattern matching. It does not handle cases where the upper bits are known to be zero through other operations without an explicit and X, 1.

2. Purpose of Improvement
Generalize the conversion from icmp eq/ne X, 0 to trunc X to i1 (or not trunc) by utilizing KnownBits.
If Known.countMinLeadingZeros() >= BitWidth - 1 for X, all bits except the LSB are guaranteed to be zero. Therefore, comparing X with 0 is mathematically equivalent to truncating X to i1.

Is folding icmp ne X, 0 to trunc X to i1 using KnownBits desirable in InstCombine?


_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to