[PATCH] D119459: [AMDGPU][GlobalISel] Fix insert point in FoldableFneg combine
Mirko Brkusanin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 11 03:12:28 PST 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5ff35ba8ae3c: [AMDGPU][GlobalISel] Fix insert point in FoldableFneg combine (authored by mbrkusanin).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D119459/new/
https://reviews.llvm.org/D119459
Files:
llvm/lib/Target/AMDGPU/AMDGPUCombinerHelper.cpp
llvm/test/CodeGen/AMDGPU/GlobalISel/combine-foldable-fneg.mir
Index: llvm/test/CodeGen/AMDGPU/GlobalISel/combine-foldable-fneg.mir
===================================================================
--- llvm/test/CodeGen/AMDGPU/GlobalISel/combine-foldable-fneg.mir
+++ llvm/test/CodeGen/AMDGPU/GlobalISel/combine-foldable-fneg.mir
@@ -777,3 +777,31 @@
$vgpr2 = COPY %7:_(s32)
...
+
+# Check if new fneg is inserted at the appropriate place
+---
+name: fneg_src_has_multiple_uses
+body: |
+ bb.0:
+ liveins: $vgpr0, $vgpr1, $vgpr2
+
+ ; CHECK-LABEL: name: fneg_src_has_multiple_uses
+ ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $vgpr0
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr1
+ ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY $vgpr2
+ ; CHECK-NEXT: [[FNEG:%[0-9]+]]:_(s32) = G_FNEG [[COPY1]]
+ ; CHECK-NEXT: [[FMUL:%[0-9]+]]:_(s32) = G_FMUL [[COPY]], [[FNEG]]
+ ; CHECK-NEXT: [[FNEG1:%[0-9]+]]:_(s32) = G_FNEG [[FMUL]]
+ ; CHECK-NEXT: [[FMUL1:%[0-9]+]]:_(s32) = G_FMUL [[FNEG1]], [[COPY2]]
+ ; CHECK-NEXT: $vgpr0 = COPY [[FMUL1]](s32)
+ ; CHECK-NEXT: $vgpr1 = COPY [[FMUL]](s32)
+ %0:_(s32) = COPY $vgpr0
+ %1:_(s32) = COPY $vgpr1
+ %2:_(s32) = COPY $vgpr2
+ %3:_(s32) = G_FMUL %0:_, %1:_
+ %4:_(s32) = G_FMUL %3:_, %2:_
+ %5:_(s32) = G_FNEG %3:_
+ $vgpr0 = COPY %4:_(s32)
+ $vgpr1 = COPY %5:_(s32)
+
+...
Index: llvm/lib/Target/AMDGPU/AMDGPUCombinerHelper.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUCombinerHelper.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUCombinerHelper.cpp
@@ -373,7 +373,8 @@
replaceRegWith(MRI, Dst, NegatedMatchInfo);
// Recreate non negated value for other uses of old MatchInfoDst
- Builder.setInstrAndDebugLoc(MI);
+ auto NextInst = ++MatchInfo->getIterator();
+ Builder.setInstrAndDebugLoc(*NextInst);
Builder.buildFNeg(MatchInfoDst, NegatedMatchInfo, MI.getFlags());
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119459.407825.patch
Type: text/x-patch
Size: 1919 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220211/973206d2/attachment.bin>
More information about the llvm-commits
mailing list