[llvm] [SLP] Make getSameOpcode support different instructions if they have same semantics. (PR #112181)
Han-Kuan Chen via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 21 17:10:28 PDT 2024
================
@@ -14935,7 +15108,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
Value *V = Builder.CreateBinOp(
static_cast<Instruction::BinaryOps>(E->getOpcode()), LHS,
RHS);
- propagateIRFlags(V, E->Scalars, VL0, It == MinBWs.end());
+ propagateIRFlags(V, E->Scalars, nullptr, It == MinBWs.end());
----------------
HanKuanChen wrote:
This is used to fix
```
- ; CHECK-NEXT: [[TMP1:%.*]] = mul nsw <4 x i32> [[SHUFFLE]], <i32 5, i32 9, i32 3, i32 10>
- ; CHECK-NEXT: [[TMP2:%.*]] = shl <4 x i32> [[SHUFFLE]], <i32 5, i32 9, i32 3, i32 10>
- ; CHECK-NEXT: [[TMP3:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> [[TMP2]], <4 x i32> <i32 0, i32 1, i32 6, i32 3>
+ ; CHECK-NEXT: [[TMP3:%.*]] = mul <4 x i32> [[SHUFFLE]], <i32 5, i32 9, i32 8, i32 10>
```
VL0 is mul here. If we pass VL0, then eventually `nsw` will be passed.
However, shl does not contain `nsw`. We should pass nullptr here to get the correct result.
https://github.com/llvm/llvm-project/pull/112181
More information about the llvm-commits
mailing list