[PATCH] D105764: [InstCombine] Fold ashr(or(neg(x),x),bw-1) --> sext(icmp_ne(x,0)) (PR50816)
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 11 04:36:24 PDT 2021
spatel added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp:1328
+
+ // ashr i32 or(X,-X), 31 --> sext (X != 0)
+ if (ShAmt == BitWidth - 1 &&
----------------
Might as well handle the `lshr` -> `zext` variant at the same time?
https://alive2.llvm.org/ce/z/SnZmSj
================
Comment at: llvm/test/Transforms/InstCombine/sub-ashr-or-to-icmp-select.ll:115
+define i32 @neg_or_ashr_i32_commute(i32 %x) {
+; CHECK-LABEL: @neg_or_ashr_i32_commute(
----------------
This isn't testing the path you intended. We always commute the `or` operands before we reach the matcher in this patch. Search for "thwart complexity" in the instcombine test directory for examples of how to work around that.
(Best to pre-commit the tests, so we can verify the patterns are as expected.)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105764/new/
https://reviews.llvm.org/D105764
More information about the llvm-commits
mailing list