[PATCH] D72396: [InstCombine] fold zext of masked bit set/clear

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 8 10:40:16 PST 2020


spatel added a comment.

I'm very surprised we didn't hit this sooner, but we have this set of 'select' folds in InstCombiner::visitSelectInst() that have existed for at least 10 years, and they are all poison-unsafe:

  Name: fval is true
    %s = select i1 %cmp1, i1 %x, i1 true
    =>
    %not = xor i1 %cmp1, true
    %s = or i1 %not, %x
  
  Name: fval is false
    %s = select i1 %cmp1, i1 %x, i1 false
    =>
    %s = and i1 %cmp1, %x
  
  Name: tval is true
    %s = select i1 %cmp1, i1 true, i1 %x
    =>
    %s = or i1 %cmp1, %x
  
  Name: tval is false
    %s = select i1 %cmp1, i1 false, i1 %x
    =>
    %not = xor i1 %cmp1, true
    %s = and i1 %not, %x


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

https://reviews.llvm.org/D72396





More information about the llvm-commits mailing list