[PATCH] D132888: [InstCombine] reduce test-for-overflow of shifted value

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 3 05:22:41 PDT 2022


spatel accepted this revision.
spatel added a comment.
This revision is now accepted and ready to land.

LGTM



================
Comment at: llvm/test/Transforms/InstCombine/icmp-shl-1-overflow.ll:117
 ;
-  %x = add <2 x i8> <i8 42, i8 42>, %_x ; thwart complexity-based canonicalization
+  %x = sdiv <2 x i8> <i8 42, i8 42>, %_x ; thwart complexity-based canonicalization
   %add = shl <2 x i8> %x, <i8 1, i8 1>
----------------
You changed this test (and one below) because there's a follow-on transform that would fold the add into the equality comparison?
It's fine to demonstrate a sequence of transforms as long as we're starting from the transform in this patch.

In fact, this result shows that we missed another optimization - the result is 0 when the input is signed >  42 or signed < -42, and that can be reduced to:
https://alive2.llvm.org/ce/z/erdvwc



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

https://reviews.llvm.org/D132888



More information about the llvm-commits mailing list