llvm.org GIT mirror llvm / 6a86bd7
Implement multiple with overflow by 2 with an add instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63090 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 11 years ago
2 changed file(s) with 31 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
36113611 (implicit EFLAGS)),
36123612 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
36133613
3614 // Optimize multiple with overflow by 2.
3615 let AddedComplexity = 2 in {
3616 def : Pat<(parallel (X86smul_ovf GR16:$src1, 2),
3617 (implicit EFLAGS)),
3618 (ADD16rr GR16:$src1, GR16:$src1)>;
3619
3620 def : Pat<(parallel (X86smul_ovf GR32:$src1, 2),
3621 (implicit EFLAGS)),
3622 (ADD32rr GR32:$src1, GR32:$src1)>;
3623 }
3624
36143625 //===----------------------------------------------------------------------===//
36153626 // Floating Point Stack Support
36163627 //===----------------------------------------------------------------------===//
0 ; RUN: llvm-as < %s | llc -march=x86 | grep mul | count 1
1 ; RUN: llvm-as < %s | llc -march=x86 | grep add | count 3
2
3 define i32 @t1(i32 %a, i32 %b) nounwind readnone {
4 entry:
5 %tmp0 = add i32 %b, %a
6 %tmp1 = call { i32, i1 } @llvm.smul.with.overflow.i32(i32 %tmp0, i32 2)
7 %tmp2 = extractvalue { i32, i1 } %tmp1, 0
8 ret i32 %tmp2
9 }
10
11 define i32 @t2(i32 %a, i32 %b) nounwind readnone {
12 entry:
13 %tmp0 = add i32 %b, %a
14 %tmp1 = call { i32, i1 } @llvm.smul.with.overflow.i32(i32 %tmp0, i32 4)
15 %tmp2 = extractvalue { i32, i1 } %tmp1, 0
16 ret i32 %tmp2
17 }
18
19 declare { i32, i1 } @llvm.smul.with.overflow.i32(i32, i32) nounwind