HomePhabricator

[InstCombine] Fold compare of int constant against a splatted vector of ints

Description

[InstCombine] Fold compare of int constant against a splatted vector of ints

Summary:
Folding patterns like:

%vec = shufflevector <4 x i8> %insvec, <4 x i8> undef, <4 x i32> zeroinitializer
%cast = bitcast <4 x i8> %vec to i32
%cond = icmp eq i32 %cast, 0

into:

%ext = extractelement <4 x i8> %insvec, i32 0
%cond = icmp eq i32 %ext, 0

Combined with existing rules, this allows us to fold patterns like:

%insvec = insertelement <4 x i8> undef, i8 %val, i32 0
%vec = shufflevector <4 x i8> %insvec, <4 x i8> undef, <4 x i32> zeroinitializer
%cast = bitcast <4 x i8> %vec to i32
%cond = icmp eq i32 %cast, 0

into:

%cond = icmp eq i8 %val, 0

When we construct a splat vector via a shuffle, and bitcast the vector into an integer type for comparison against an integer constant. Then we can simplify the the comparison to compare the splatted value against the integer constant.

Reviewers: spatel, anna, mkazantsev

Reviewed By: spatel

Subscribers: efriedma, rengolin, llvm-commits

Differential Revision: https://reviews.llvm.org/D44997

Details

Committed
dneilsonApr 3 2018, 10:26 AM
Reviewer
spatel
Differential Revision
D44997: [InstCombine] Fold compare of int constant against a splatted vector of ints
Parents
rL329086: [ELF] - Eliminate Lazy class.
Branches
Unknown
Tags
Unknown