[PATCH] D48987: [InstCombine] drop poison flags for shuffle transforms with undefs

Nuno Lopes via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 6 01:12:59 PDT 2018


nlopes added inline comments.


================
Comment at: test/Transforms/InstCombine/shuffle_select.ll:521
 ; CHECK-NEXT:    [[TMP1:%.*]] = shufflevector <4 x i32> [[V0:%.*]], <4 x i32> [[V1:%.*]], <4 x i32> <i32 undef, i32 5, i32 2, i32 undef>
-; CHECK-NEXT:    [[T3:%.*]] = shl nsw <4 x i32> [[TMP1]], <i32 undef, i32 6, i32 3, i32 undef>
+; CHECK-NEXT:    [[T3:%.*]] = shl <4 x i32> [[TMP1]], <i32 undef, i32 6, i32 3, i32 undef>
 ; CHECK-NEXT:    ret <4 x i32> [[T3]]
----------------
spatel wrote:
> nlopes wrote:
> > Everything looks good, except this one.
> > As discussed in the other patch, `a << undef` is poison, so you can't introduce it. (since it's not correct to replace undef with poison).
> Hmm...how is this case different than the 'shl_shl' above?
> 
> Are there 4 cases?
> 1. Instructions with immediate UB (srem, urem).
> 2. Instructions with immediate UB and poison with flags (sdiv, udiv).
> 3. Instructions with poison regardless of flags (shl, ashr, lshr).
> 4. Instructions with poison only with flags (mul, add, sub).
> 
> 
This case is the same as shl_shl, yes.

Your 4 cases are correct. I would only add that case 3 is poison regardless of flags + poison with flags.


https://reviews.llvm.org/D48987





More information about the llvm-commits mailing list