Skip to content
Commit 075202d1 authored by Han Zhu's avatar Han Zhu
Browse files

[X86 isel] Fix permute mask calculation in lowerShuffleAsUNPCKAndPermute

This fixes [issue 62242](https://github.com/llvm/llvm-project/issues/62242)

This code block can potentially swap the order of V1 and V2 in Ops and therefore
also in the unpck instruction generated.
```
SDValue &Op = Ops[Elt & 1];
if (M < NumElts && (Op.isUndef() || Op == V1))
  Op = V1;
else if (NumElts <= M && (Op.isUndef() || Op == V2)) {
  Op = V2;
  NormM -= NumElts;
} else
  return SDValue();
```
But the permute mask is calculated assuming the first operand being V1 and
second V2, therefore causing a mis-compile.

First check if the input operands are swapped, and then calculate the permute
mask based on that.

Differential Revision: https://reviews.llvm.org/D148843
parent 7090c102
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment