[InstCombine] add narrowing transform for low-masked binop with zext operand (2nd...
authorSanjay Patel <spatel@rotateright.com>
Fri, 10 Jun 2022 14:44:13 +0000 (10:44 -0400)
committerSanjay Patel <spatel@rotateright.com>
Fri, 10 Jun 2022 16:42:27 +0000 (12:42 -0400)
commite247b0e5c92185e9e9cce7bae36fab8756085a82
treee569cd2b6a952c827b1742d133eb3fbdf6cfee4a
parent4c3139d7b935d441cf616c968217b171af5d311a
[InstCombine] add narrowing transform for low-masked binop with zext operand (2nd try)

The 1st try ( afa192cfb6049a15c55 ) was reverted because it could
cause an infinite loop with constant expressions.

A test for that and an extra condition to enable the transform
are added now. I also added code comments to better describe
the transform and the existing, related transform.

Original commit message:
https://alive2.llvm.org/ce/z/hRy3rE

As shown in D123408, we can produce this pattern when moving
casts around, and we already have a related fold for a binop
with a constant operand.
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/test/Transforms/InstCombine/and.ll
llvm/test/Transforms/InstCombine/cast_phi.ll