[llvm] r313669 - [SystemZ] Fix truncstore + bswap codegen bug

Ulrich Weigand via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 19 13:50:05 PDT 2017


Author: uweigand
Date: Tue Sep 19 13:50:05 2017
New Revision: 313669

URL: http://llvm.org/viewvc/llvm-project?rev=313669&view=rev
Log:
[SystemZ] Fix truncstore + bswap codegen bug

SystemZTargetLowering::combineSTORE contains code to transform a
combination of STORE + BSWAP into a STRV type instruction.

This transformation is correct for regular stores, but not for
truncating stores.  The routine neglected to check for that case.

Fixes a miscompilation of llvm-objcopy with clang, which caused
test suite failures in the SystemZ multistage build bot.


Added:
    llvm/trunk/test/CodeGen/SystemZ/bswap-08.ll
Modified:
    llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp

Modified: llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp?rev=313669&r1=313668&r2=313669&view=diff
==============================================================================
--- llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp Tue Sep 19 13:50:05 2017
@@ -5225,7 +5225,8 @@ SDValue SystemZTargetLowering::combineST
   }
   // Combine STORE (BSWAP) into STRVH/STRV/STRVG
   // See comment in combineBSWAP about volatile accesses.
-  if (!SN->isVolatile() &&
+  if (!SN->isTruncatingStore() &&
+      !SN->isVolatile() &&
       Op1.getOpcode() == ISD::BSWAP &&
       Op1.getNode()->hasOneUse() &&
       (Op1.getValueType() == MVT::i16 ||

Added: llvm/trunk/test/CodeGen/SystemZ/bswap-08.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/SystemZ/bswap-08.ll?rev=313669&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/SystemZ/bswap-08.ll (added)
+++ llvm/trunk/test/CodeGen/SystemZ/bswap-08.ll Tue Sep 19 13:50:05 2017
@@ -0,0 +1,17 @@
+; Verify that truncating stores do not use STRV
+;
+; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
+
+declare i64 @llvm.bswap.i64(i64)
+
+define void @f1(i32* %x, i64* %y) {
+; CHECK-LABEL: f1:
+; CHECK-NOT: strv
+; CHECK: br %r14
+  %a = load i64, i64* %y, align 8
+  %b = tail call i64 @llvm.bswap.i64(i64 %a)
+  %conv = trunc i64 %b to i32
+  store i32 %conv, i32* %x, align 4
+  ret void
+}
+




More information about the llvm-commits mailing list