[PATCH] D79171: [InstCombine] canonicalize bitcast after insertelement into undef

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 30 11:15:06 PDT 2020


spatel added a comment.

In D79171#2013138 <https://reviews.llvm.org/D79171#2013138>, @craig.topper wrote:

> I messed with mmx in this area once and regretted it. See rG5ebbabc1af360756f402203ba7704bb480f279a7 <https://reviews.llvm.org/rG5ebbabc1af360756f402203ba7704bb480f279a7>


Sufficiently scared. Will remove mmx diffs.

> Is canonicalizing towards a vector type that wasn't mentioned in the IR the right way to go? Is that cast free for legal types on all targets? I think its potentially scalarized or becomes a load/store to stack temporary for illegal types in the backend.

I think we're fine here. The vector bitcast that we are creating is only changing the element type (FP <-> int), and we assume that both of those are ok since they are already in the code independent of this transform. 
The vector cast is likely safer than the scalar cast on most targets because it's probably not causing any underlying register move (assuming vector registers hold both int and FP). So even if the vector type is illegal, the obvious lowering is a no-op cast to the legal vector type.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79171/new/

https://reviews.llvm.org/D79171





More information about the llvm-commits mailing list