[PATCH] D144333: [DivRemPairs] Strip division's poison generating flag
Juneyoung Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 18 13:01:18 PST 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2ad0cc9186d4: [DivRemPairs] Strip division's poison generating flag (authored by aqjune).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144333/new/
https://reviews.llvm.org/D144333
Files:
llvm/lib/Transforms/Scalar/DivRemPairs.cpp
llvm/test/Transforms/DivRemPairs/AArch64/div-rem-pairs.ll
Index: llvm/test/Transforms/DivRemPairs/AArch64/div-rem-pairs.ll
===================================================================
--- llvm/test/Transforms/DivRemPairs/AArch64/div-rem-pairs.ll
+++ llvm/test/Transforms/DivRemPairs/AArch64/div-rem-pairs.ll
@@ -5,7 +5,7 @@
; CHECK-LABEL: @f(
; CHECK-NEXT: [[X_FROZEN:%.*]] = freeze i8 [[X:%.*]]
; CHECK-NEXT: [[Y_FROZEN:%.*]] = freeze i8 [[Y:%.*]]
-; CHECK-NEXT: [[XDIVY:%.*]] = udiv exact i8 [[X_FROZEN]], [[Y_FROZEN]]
+; CHECK-NEXT: [[XDIVY:%.*]] = udiv i8 [[X_FROZEN]], [[Y_FROZEN]]
; CHECK-NEXT: [[TMP1:%.*]] = mul i8 [[XDIVY]], [[Y_FROZEN]]
; CHECK-NEXT: [[XMODY_DECOMPOSED:%.*]] = sub i8 [[X_FROZEN]], [[TMP1]]
; CHECK-NEXT: store i8 [[XMODY_DECOMPOSED]], ptr [[P:%.*]], align 1
Index: llvm/lib/Transforms/Scalar/DivRemPairs.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/DivRemPairs.cpp
+++ llvm/lib/Transforms/Scalar/DivRemPairs.cpp
@@ -371,6 +371,10 @@
Mul->insertAfter(RemInst);
Sub->insertAfter(Mul);
+ // If DivInst has the exact flag, remove it. Otherwise this optimization
+ // may replace a well-defined value 'X % Y' with poison.
+ DivInst->dropPoisonGeneratingFlags();
+
// If X can be undef, X should be frozen first.
// For example, let's assume that Y = 1 & X = undef:
// %div = sdiv undef, 1 // %div = undef
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144333.498620.patch
Type: text/x-patch
Size: 1416 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230218/868974e9/attachment.bin>
More information about the llvm-commits
mailing list