[PATCH] D17261: [X86] PR26575: Fix LEA optimization pass.

Andrey Turetskiy via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 16 04:52:16 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL260959: [X86] PR26575: Fix LEA optimization pass. (authored by aturetsk).

Changed prior to commit:
  http://reviews.llvm.org/D17261?vs=47967&id=48065#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17261

Files:
  llvm/trunk/lib/Target/X86/X86OptimizeLEAs.cpp
  llvm/trunk/test/CodeGen/X86/lea-opt-memop-check.ll

Index: llvm/trunk/test/CodeGen/X86/lea-opt-memop-check.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/lea-opt-memop-check.ll
+++ llvm/trunk/test/CodeGen/X86/lea-opt-memop-check.ll
@@ -0,0 +1,32 @@
+; REQUIRES: asserts
+; RUN: llc < %s -march=x86 -mtriple=i686-pc-win32 -enable-x86-lea-opt | FileCheck %s
+
+; PR26575
+; Assertion `(Disp->isImm() || Disp->isGlobal()) && (Other.Disp->isImm() || Other.Disp->isGlobal()) && "Address displacement operand is always an immediate or a global"' failed.
+
+target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
+target triple = "i686-pc-windows-msvc"
+
+declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i32, i1) argmemonly nounwind
+declare <2 x i64> @_mm_xor_si128(<2 x i64>, <2 x i64>) optsize
+declare <2 x i64> @llvm.x86.pclmulqdq(<2 x i64>, <2 x i64>, i8) nounwind readnone
+declare <4 x float> @_mm_castsi128_ps(<2 x i64>) optsize
+
+define void @test(i8* nocapture readonly %src, i32 %len) #0 {
+  %parts = alloca [4 x i32], align 4
+  %part0 = bitcast [4 x i32]* %parts to i8*
+  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %part0, i8* %src, i32 %len, i32 1, i1 false)
+  %call0 = tail call <2 x i64> @_mm_xor_si128(<2 x i64> undef, <2 x i64> <i64 -9187201950435737472, i64 -9187201950435737472>)
+  %tmp0 = tail call <2 x i64> @llvm.x86.pclmulqdq(<2 x i64> undef, <2 x i64> <i64 7631803798, i64 5708721108>, i8 16)
+  %call1 = tail call <4 x float> @_mm_castsi128_ps(<2 x i64> %tmp0)
+  ret void
+; CHECK-LABEL: test:
+; CHECK:	leal{{.*}}
+; CHECK:	calll _memcpy
+; CHECK:	movaps __xmm@{{[0-9a-f]+}}, %xmm1
+; CHECK:	calll __mm_xor_si128
+; CHECK:	pclmulqdq $16, __xmm@{{[0-9a-f]+}}, %xmm0
+; CHECK:	jmp __mm_castsi128_ps
+}
+
+attributes #0 = { nounwind optsize "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-features"="+mmx,+pclmul,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3" "unsafe-fp-math"="false" "use-soft-float"="false" }
Index: llvm/trunk/lib/Target/X86/X86OptimizeLEAs.cpp
===================================================================
--- llvm/trunk/lib/Target/X86/X86OptimizeLEAs.cpp
+++ llvm/trunk/lib/Target/X86/X86OptimizeLEAs.cpp
@@ -434,6 +434,11 @@
 
     MemOpNo += X86II::getOperandBias(Desc);
 
+    // Address displacement must be an immediate or a global.
+    MachineOperand &Disp = MI.getOperand(MemOpNo + X86::AddrDisp);
+    if (!Disp.isImm() && !Disp.isGlobal())
+      continue;
+
     // Get the best LEA instruction to replace address calculation.
     MachineInstr *DefMI;
     int64_t AddrDispShift;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17261.48065.patch
Type: text/x-patch
Size: 2735 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160216/aeaa2ab2/attachment.bin>


More information about the llvm-commits mailing list