[llvm-branch-commits] [llvm] da72df4 - [SVE] Fix bug in SVEIntrinsicOpts::optimizePTest

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Aug 18 01:07:17 PDT 2020


Author: David Sherwood
Date: 2020-08-18T10:02:50+02:00
New Revision: da72df44005c909e40af867843168c4c456baa3d

URL: https://github.com/llvm/llvm-project/commit/da72df44005c909e40af867843168c4c456baa3d
DIFF: https://github.com/llvm/llvm-project/commit/da72df44005c909e40af867843168c4c456baa3d.diff

LOG: [SVE] Fix bug in SVEIntrinsicOpts::optimizePTest

The code wasn't taking into account that the two operands
passed to ptest could be identical and was trying to erase
them twice.

Differential Revision: https://reviews.llvm.org/D85892

(cherry picked from commit 6c7957c9901714b7ad0a8d2743a8c431b57fd0c9)

Added: 
    

Modified: 
    llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp
    llvm/test/CodeGen/AArch64/sve-intrinsic-opts-ptest.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp b/llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp
index 74fe0cdd1ea7..0245dd1d611a 100644
--- a/llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp
+++ b/llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp
@@ -160,7 +160,7 @@ bool SVEIntrinsicOpts::optimizePTest(IntrinsicInst *I) {
     I->eraseFromParent();
     if (Op1->use_empty())
       Op1->eraseFromParent();
-    if (Op2->use_empty())
+    if (Op1 != Op2 && Op2->use_empty())
       Op2->eraseFromParent();
 
     return true;

diff  --git a/llvm/test/CodeGen/AArch64/sve-intrinsic-opts-ptest.ll b/llvm/test/CodeGen/AArch64/sve-intrinsic-opts-ptest.ll
index 191fddacffd1..9af34676b342 100644
--- a/llvm/test/CodeGen/AArch64/sve-intrinsic-opts-ptest.ll
+++ b/llvm/test/CodeGen/AArch64/sve-intrinsic-opts-ptest.ll
@@ -44,6 +44,16 @@ define i1 @ptest_first(<vscale x 4 x i1> %a) {
   ret i1 %out
 }
 
+define i1 @ptest_first_same_ops(<vscale x 2 x i1> %a) {
+; OPT-LABEL: ptest_first_same_ops
+; OPT: %[[OUT:.*]] = call i1 @llvm.aarch64.sve.ptest.first.nxv2i1(<vscale x 2 x i1> %a, <vscale x 2 x i1> %a)
+; OPT-NOT: convert
+; OPT-NEXT: ret i1 %[[OUT]]
+  %1 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv2i1(<vscale x 2 x i1> %a)
+  %2 = tail call i1 @llvm.aarch64.sve.ptest.first.nxv16i1(<vscale x 16 x i1> %1, <vscale x 16 x i1> %1)
+  ret i1 %2
+}
+
 define i1 @ptest_last(<vscale x 8 x i1> %a) {
 ; OPT-LABEL: ptest_last
 ; OPT: %mask = tail call <vscale x 8 x i1> @llvm.aarch64.sve.ptrue.nxv8i1(i32 0)


        


More information about the llvm-branch-commits mailing list