[PATCH] Fix for PR23103. Correctly propagate the 'IsUndef' flag to the register operands of a commuted instruction.

Phabricator reviews at reviews.llvm.org
Thu Apr 30 14:06:59 PDT 2015


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D9406

Files:
  llvm/trunk/lib/CodeGen/TargetInstrInfo.cpp
  llvm/trunk/test/CodeGen/X86/pr23103.ll

Index: llvm/trunk/lib/CodeGen/TargetInstrInfo.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/TargetInstrInfo.cpp
+++ llvm/trunk/lib/CodeGen/TargetInstrInfo.cpp
@@ -142,6 +142,8 @@
   unsigned SubReg2 = MI->getOperand(Idx2).getSubReg();
   bool Reg1IsKill = MI->getOperand(Idx1).isKill();
   bool Reg2IsKill = MI->getOperand(Idx2).isKill();
+  bool Reg1IsUndef = MI->getOperand(Idx1).isUndef();
+  bool Reg2IsUndef = MI->getOperand(Idx2).isUndef();
   // If destination is tied to either of the commuted source register, then
   // it must be updated.
   if (HasDef && Reg0 == Reg1 &&
@@ -172,6 +174,8 @@
   MI->getOperand(Idx1).setSubReg(SubReg2);
   MI->getOperand(Idx2).setIsKill(Reg1IsKill);
   MI->getOperand(Idx1).setIsKill(Reg2IsKill);
+  MI->getOperand(Idx2).setIsUndef(Reg1IsUndef);
+  MI->getOperand(Idx1).setIsUndef(Reg2IsUndef);
   return MI;
 }
 
Index: llvm/trunk/test/CodeGen/X86/pr23103.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/pr23103.ll
+++ llvm/trunk/test/CodeGen/X86/pr23103.ll
@@ -0,0 +1,21 @@
+; RUN: llc -verify-machineinstrs -mtriple=x86_64-unknown-unknown -mcpu=generic -mattr=+avx < %s | FileCheck %s
+
+; When commuting a VADDSDrr instruction, verify that the 'IsUndef' flag is
+; correctly propagated to the operands of the resulting instruction.
+; Test for PR23103;
+
+declare zeroext i1 @foo(<1 x double>)
+
+define <1 x double> @pr23103(<1 x double>* align 8 %Vp) {
+; CHECK-LABEL: pr23103:
+; CHECK:         vmovsd (%rdi), %xmm0
+; CHECK-NEXT:    vmovsd %xmm0, {{.*}}(%rsp) {{.*#+}} 8-byte Spill
+; CHECK-NEXT:    callq foo
+; CHECK-NEXT:    vaddsd {{.*}}(%rsp), %xmm0, %xmm0 {{.*#+}} 8-byte Folded Reload
+; CHECK:         retq
+entry:
+  %V = load <1 x double>, <1 x double>* %Vp, align 8
+  %call = call zeroext i1 @foo(<1 x double> %V)
+  %fadd = fadd <1 x double> %V, undef
+  ret <1 x double> %fadd
+}

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9406.24767.patch
Type: text/x-patch
Size: 1954 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150430/d581d9ab/attachment.bin>


More information about the llvm-commits mailing list