Skip to content

[VectorCombine] foldBitOpOfCastops - failure to handle bitop(castop(x), constant_y) -> castop(bitop(x, invcast(constant_y))) #154797

@RKSimon

Description

@RKSimon

foldBitOpOfCastops currently just folds bitop(castop(x), castop(y)) -> castop(bitop(x, y))

But we often have operands that have already constant folded the castop away which prevents the fold from proceeding.

The most obvious are not patterns:

  %x.cast = bitcast <4 x i32> %x to <2 x i64>
  %not = xor <2 x i64>%x.cast, splat (i64 -1)

-->

  %not.cast = <4 x i32> %x, splat (i32 -1)
  %not = bitcast <4 x i32> %not.cast to <2 x i64>

Any other bitcasted constants would be easy to handle as well.

But other casts that can be easily inverted (truncations, in range sext/zext etc.) could be handled as well.

Metadata

Metadata

Assignees

Labels

good first issuehttps://github.com/llvm/llvm-project/contributellvm::vectorcombineCost-based vector combine pass

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions