[PATCH] Added InstCombine for ((1 << X) & C) pattern

Dinesh Dwivedi dinesh.d at samsung.com
Thu May 8 08:01:30 PDT 2014


Hi nadav, rafael, chandlerc,

Basically this patch transforms
(1 << X) & C -> (X == lg(C)) ? (1 << X) : 0, if C is Power of 2
(1 << X) & C -> (X < lg(C+1)) ? (1 << X) : 0, if C + 1 is Power of 2

This patch can handles following cases from http://nondot.org/sabre/LLVMNotes/InstCombine.txt

-      if (!((1 << which_alternative) & 0x3))
+      if (which_alternative >= 2)

-      if (((1 << which_alternative) & 0x7))
+      if (which_alternative < 3)

I need suggestion regarding this
1. Names for comp and select instruction, for now, it is getting set automatically.
2. Do we have to have check if X is not greater than the bit-width
3. If check for the last of added test-case is ok.

http://reviews.llvm.org/D3678

Files:
  lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
  test/Transforms/InstCombine/icmp.ll
  test/Transforms/InstCombine/shift.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3678.9223.patch
Type: text/x-patch
Size: 3369 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140508/b0862826/attachment.bin>


More information about the llvm-commits mailing list