[llvm-commits] [llvm] r61281 - in /llvm/trunk: lib/Target/X86/X86FastISel.cpp test/CodeGen/X86/fast-isel-shift-imm.ll

Dan Gohman gohman at apple.com
Sat Dec 20 09:19:41 PST 2008


Author: djg
Date: Sat Dec 20 11:19:40 2008
New Revision: 61281

URL: http://llvm.org/viewvc/llvm-project?rev=61281&view=rev
Log:
Fix fast-isel to not emit invalid assembly when presented with a
constant shift count that doesn't fit in the shift instruction's
immediate field. This fixes PR3242.

Added:
    llvm/trunk/test/CodeGen/X86/fast-isel-shift-imm.ll
Modified:
    llvm/trunk/lib/Target/X86/X86FastISel.cpp

Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=61281&r1=61280&r2=61281&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Sat Dec 20 11:19:40 2008
@@ -893,7 +893,7 @@
   if (ConstantInt *CI = dyn_cast<ConstantInt>(I->getOperand(1))) {
     unsigned ResultReg = createResultReg(RC);
     BuildMI(MBB, TII.get(OpImm), 
-            ResultReg).addReg(Op0Reg).addImm(CI->getZExtValue());
+            ResultReg).addReg(Op0Reg).addImm(CI->getZExtValue() & 0xff);
     UpdateValueMap(I, ResultReg);
     return true;
   }

Added: llvm/trunk/test/CodeGen/X86/fast-isel-shift-imm.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel-shift-imm.ll?rev=61281&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/X86/fast-isel-shift-imm.ll (added)
+++ llvm/trunk/test/CodeGen/X86/fast-isel-shift-imm.ll Sat Dec 20 11:19:40 2008
@@ -0,0 +1,7 @@
+; RUN: llvm-as < %s | llc -march=x86 -fast | grep {sarl	\$80, %eax}
+; PR3242
+
+define i32 @foo(i32 %x) nounwind {
+  %y = ashr i32 %x, 50000
+  ret i32 %y
+}





More information about the llvm-commits mailing list