llvm-6502/test/Transforms/InstCombine/align-2d-gep.ll
Dan Gohman eee962e1ce Teach InstCombine's ComputeMaskedBits to handle pointer expressions
in addition to integer expressions. Rewrite GetOrEnforceKnownAlignment
as a ComputeMaskedBits problem, moving all of its special alignment
knowledge to ComputeMaskedBits as low-zero-bits knowledge.

Also, teach ComputeMaskedBits a few basic things about Mul and PHI
instructions.

This improves ComputeMaskedBits-based simplifications in a few cases,
but more noticeably it significantly improves instcombine's alignment
detection for loads, stores, and memory intrinsics.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49492 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-10 18:43:06 +00:00

44 lines
1.4 KiB
LLVM

; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {align 16} | count 1
; A multi-dimensional array in a nested loop doing vector stores that
; aren't yet aligned. Instcombine can understand the addressing in the
; Nice case to prove 16 byte alignment. In the Awkward case, the inner
; array dimension is not even, so the stores to it won't always be
; aligned. Instcombine should prove alignment in exactly one of the two
; stores.
@Nice = global [1001 x [20000 x double]] zeroinitializer, align 32
@Awkward = global [1001 x [20001 x double]] zeroinitializer, align 32
define void @foo() nounwind {
entry:
br label %bb7.outer
bb7.outer:
%i = phi i64 [ 0, %entry ], [ %indvar.next26, %bb11 ]
br label %bb1
bb1:
%j = phi i64 [ 0, %bb7.outer ], [ %indvar.next, %bb1 ]
%t4 = getelementptr [1001 x [20000 x double]]* @Nice, i64 0, i64 %i, i64 %j
%q = bitcast double* %t4 to <2 x double>*
store <2 x double><double 0.0, double 0.0>, <2 x double>* %q, align 8
%s4 = getelementptr [1001 x [20001 x double]]* @Awkward, i64 0, i64 %i, i64 %j
%r = bitcast double* %s4 to <2 x double>*
store <2 x double><double 0.0, double 0.0>, <2 x double>* %r, align 8
%indvar.next = add i64 %j, 2
%exitcond = icmp eq i64 %indvar.next, 557
br i1 %exitcond, label %bb11, label %bb1
bb11:
%indvar.next26 = add i64 %i, 1
%exitcond27 = icmp eq i64 %indvar.next26, 991
br i1 %exitcond27, label %return.split, label %bb7.outer
return.split:
ret void
}