[llvm] [DAGCombiner] Fix to avoid writing outside original store in ReduceLoadOpStoreWidth (PR #119203)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 11 02:23:07 PST 2024


================
@@ -20352,19 +20357,38 @@ SDValue DAGCombiner::ReduceLoadOpStoreWidth(SDNode *N) {
     EVT NewVT = EVT::getIntegerVT(*DAG.getContext(), NewBW);
     // The narrowing should be profitable, the load/store operation should be
     // legal (or custom) and the store size should be equal to the NewVT width.
-    while (NewBW < BitWidth && (NewVT.getStoreSizeInBits() != NewBW ||
-                                !TLI.isOperationLegalOrCustom(Opc, NewVT) ||
-                                !TLI.isNarrowingProfitable(N, VT, NewVT))) {
+    while (NewBW < BitWidth &&
+           (NewVT.getStoreSizeInBits() != NewBW ||
+            !TLI.isOperationLegalOrCustom(Opc, NewVT) ||
+            !(TLI.isNarrowingProfitable(N, VT, NewVT) ||
+              ReduceLoadOpStoreWidthForceNarrowingProfitable))) {
----------------
arsenm wrote:

Swap conditions and demorgan condition 

https://github.com/llvm/llvm-project/pull/119203


More information about the llvm-commits mailing list