[PATCH] D113564: [DAG] FoldConstantArithmetic - fold intop(bitcast(buildvector(c1)),bitcast(buildvector(c1))) -> bitcast(intop(buildvector(c1'),buildvector(c2')))

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 10 05:54:17 PST 2021


RKSimon created this revision.
RKSimon added reviewers: spatel, dmgreen, lebedev.ri, craig.topper, efriedma, pengfei.
Herald added a subscriber: hiraditya.
RKSimon requested review of this revision.
Herald added a project: LLVM.

Enable FoldConstantArithmetic to constant fold bitcasted constant build vectors. These have typically been bitcasted for type legalization purposes.

By extracting the raw constant bit data, performing the constant fold, and then casting the constant bit data back to the (legalized) type, we can perform constant folding on integer types after legalization.

This in particular helps 32-bit targets which need to handle vXi64 build vectors - during legalization the (unsupported) i64 elements are split to create a bitcasted v2Xi32 build vector.

Addresses some regressions in D113192 <https://reviews.llvm.org/D113192>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113564

Files:
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/test/CodeGen/X86/packss.ll
  llvm/test/CodeGen/X86/vector-fshl-rot-128.ll
  llvm/test/CodeGen/X86/vector-fshr-rot-128.ll
  llvm/test/CodeGen/X86/vector-shift-ashr-128.ll
  llvm/test/CodeGen/X86/vector-shift-ashr-256.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113564.386131.patch
Type: text/x-patch
Size: 10590 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211110/3c3e17c0/attachment.bin>


More information about the llvm-commits mailing list