From b51a68681a005a0f209094438d08d92affda6679 Mon Sep 17 00:00:00 2001 From: Quentin Colombet Date: Tue, 18 Jun 2013 20:14:39 +0000 Subject: During SelectionDAG building explicitly set a node to constant zero when the value is zero. This allows optmizations to kick in more easily. Fix some test cases so that they remain meaningful (i.e., not completely dead coded) when optimizations apply. superfluous multiply by high part of zero-extended value. llvm-svn: 184222 --- llvm/test/CodeGen/X86/i128-mul.ll | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'llvm/test/CodeGen/X86/i128-mul.ll') diff --git a/llvm/test/CodeGen/X86/i128-mul.ll b/llvm/test/CodeGen/X86/i128-mul.ll index e9d30d67019..c0b85dfd211 100644 --- a/llvm/test/CodeGen/X86/i128-mul.ll +++ b/llvm/test/CodeGen/X86/i128-mul.ll @@ -1,4 +1,4 @@ -; RUN: llc < %s -march=x86-64 +; RUN: llc < %s -march=x86-64 | FileCheck %s ; PR1198 define i64 @foo(i64 %x, i64 %y) { @@ -10,3 +10,37 @@ define i64 @foo(i64 %x, i64 %y) { %tmp4 = trunc i128 %tmp3 to i64 ret i64 %tmp4 } + +; superfluous multiply by high part of +; zero-extended value. +; CHECK: @mul1 +; CHECK-NOT: imulq +; CHECK: mulq +; CHECK-NOT: imulq +define i64 @mul1(i64 %n, i64* nocapture %z, i64* nocapture %x, i64 %y) { +entry: + %conv = zext i64 %y to i128 + %cmp11 = icmp eq i64 %n, 0 + br i1 %cmp11, label %for.end, label %for.body + +for.body: ; preds = %entry, %for.body + %carry.013 = phi i64 [ %conv6, %for.body ], [ 0, %entry ] + %i.012 = phi i64 [ %inc, %for.body ], [ 0, %entry ] + %arrayidx = getelementptr inbounds i64* %x, i64 %i.012 + %0 = load i64* %arrayidx, align 8 + %conv2 = zext i64 %0 to i128 + %mul = mul i128 %conv2, %conv + %conv3 = zext i64 %carry.013 to i128 + %add = add i128 %mul, %conv3 + %conv4 = trunc i128 %add to i64 + %arrayidx5 = getelementptr inbounds i64* %z, i64 %i.012 + store i64 %conv4, i64* %arrayidx5, align 8 + %shr = lshr i128 %add, 64 + %conv6 = trunc i128 %shr to i64 + %inc = add i64 %i.012, 1 + %exitcond = icmp eq i64 %inc, %n + br i1 %exitcond, label %for.end, label %for.body + +for.end: ; preds = %for.body, %entry + ret i64 0 +} -- cgit v1.2.3