Skip to content

[InstCombine] eliminate bitcasts around bitwise logic ops when one input type and output type match #28299

@rotateright

Description

@rotateright
Bugzilla Link 27925
Version trunk
OS All
CC @efriedma-quic,@hfinkel,@RKSimon

Extended Description

define <4 x i32> @​bitcasts(<4 x i32> %a, <8 x i16> %b) {
%bc1 = bitcast <4 x i32> %a to <2 x i64>
%bc2 = bitcast <8 x i16> %b to <2 x i64>
%and = and <2 x i64> %bc2, %bc1
%bc3 = bitcast <2 x i64> %and to <4 x i32>
ret <4 x i32> %bc3
}

By transforming the 'and' to <4 x i32> type, we eliminate 2 bitcasts:

define <4 x i32> @​bitcasts(<4 x i32> %a, <8 x i16> %b) {
%bc2 = bitcast <8 x i16> %b to <4 x i32>
%and = and <4 x i32> %a, %bc2
ret <4 x i32> %and
}

Should this be limited to vector types?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillallvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions