[PATCH] D87046: [PPC] Do not emit extswsli in 32BIT mode when using -mcpu=pwr9

Zarko Todorovski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 21 05:15:16 PDT 2020


ZarkoCA updated this revision to Diff 293144.
ZarkoCA marked 3 inline comments as done.
ZarkoCA added a comment.

Moved `!Subtarget.isPPC64()` check earlier alongside other checks.

Reworked test case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87046/new/

https://reviews.llvm.org/D87046

Files:
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/ppc-32bit-shift.ll


Index: llvm/test/CodeGen/PowerPC/ppc-32bit-shift.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/ppc-32bit-shift.ll
@@ -0,0 +1,22 @@
+; RUN: llc -verify-machineinstrs -mtriple=powerpc \
+; RUN:     -mcpu=pwr9 < %s | FileCheck %s --check-prefix=32BIT
+
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64 \
+; RUN:     -mcpu=pwr9 < %s | FileCheck %s --check-prefix=64BIT
+
+define dso_local void @a(i32 %inta, i64* %long_intb) {
+  entry:
+    %conv = sext i32 %inta to i64
+    %shl = shl nsw i64 %conv, 8
+    store i64 %shl, i64* %long_intb, align 8
+    ret void
+}
+
+; CHECK-LABEL:     .a
+
+; 32BIT:           srawi [[REG1:[0-9]+]], [[REG2:[0-9]+]]
+; 32BIT-NEXT:      rotlwi [[REG3:[0-9]+]], [[REG2]], [[REG4:[0-9]+]]
+; 32BIT-NEXT:      slwi [[REG2]], [[REG2]], [[REG4]]
+; 32BIT-NEXT:      rlwimi [[REG3]], {{[0-9]+}}, [[REG4]], {{[0-9]+}}, {{[0-9]+}}
+
+; 64BIT:           extswsli {{[0-9]+}}, {{[0-9]+}}, {{[0-9]+}} 
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -16129,10 +16129,10 @@
 
   SDValue N0 = N->getOperand(0);
   ConstantSDNode *CN1 = dyn_cast<ConstantSDNode>(N->getOperand(1));
-  if (!Subtarget.isISA3_0() ||
+  if (!Subtarget.isISA3_0() || !Subtarget.isPPC64() ||
       N0.getOpcode() != ISD::SIGN_EXTEND ||
-      N0.getOperand(0).getValueType() != MVT::i32 ||
-      CN1 == nullptr || N->getValueType(0) != MVT::i64)
+      N0.getOperand(0).getValueType() != MVT::i32 || CN1 == nullptr ||
+      N->getValueType(0) != MVT::i64)
     return SDValue();
 
   // We can't save an operation here if the value is already extended, and


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87046.293144.patch
Type: text/x-patch
Size: 1798 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200921/3e896969/attachment.bin>


More information about the llvm-commits mailing list