From a7b65c30a3645dbd2ec46c728332e6ab6183fdf0 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 18 Jul 2007 16:29:46 +0000 Subject: [PATCH] It's not necessary to do rounding for alloca operations when the requested alignment is equal to the stack alignment. llvm-svn: 40004 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 10 +++++----- llvm/test/CodeGen/X86/alloca-align-rounding.ll | 9 +++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 llvm/test/CodeGen/X86/alloca-align-rounding.ll diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index d4651fd6abc0..9256faabeb15 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -2327,13 +2327,13 @@ void SelectionDAGLowering::visitAlloca(AllocaInst &I) { AllocSize = DAG.getNode(ISD::MUL, IntPtr, AllocSize, getIntPtrConstant(TySize)); - // Handle alignment. If the requested alignment is less than or equal to the - // stack alignment, ignore it and round the size of the allocation up to the - // stack alignment size. If the size is greater than the stack alignment, we - // note this in the DYNAMIC_STACKALLOC node. + // Handle alignment. If the requested alignment is less than the stack + // alignment, ignore it and round the size of the allocation up to the stack + // alignment size. If the size is greater than or equal to the stack + // alignment, we note this in the DYNAMIC_STACKALLOC node. unsigned StackAlign = TLI.getTargetMachine().getFrameInfo()->getStackAlignment(); - if (Align <= StackAlign) { + if (Align < StackAlign) { Align = 0; // Add SA-1 to the size. AllocSize = DAG.getNode(ISD::ADD, AllocSize.getValueType(), AllocSize, diff --git a/llvm/test/CodeGen/X86/alloca-align-rounding.ll b/llvm/test/CodeGen/X86/alloca-align-rounding.ll new file mode 100644 index 000000000000..899dbffd4f67 --- /dev/null +++ b/llvm/test/CodeGen/X86/alloca-align-rounding.ll @@ -0,0 +1,9 @@ +; RUN: llvm-as < %s | llc -march=x86-64 | not grep and + +declare void @bar(<2 x i64>* %n) + +define void @foo(i32 %h) { + %p = alloca <2 x i64>, i32 %h + call void @bar(<2 x i64>* %p) + ret void +}