llvm.org GIT mirror llvm / 99b653c
Propagate zest through logical shift. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91378 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 10 years ago
3 changed file(s) with 61 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
32773277 if (SCC.getNode()) return SCC;
32783278 }
32793279
3280 // (zext (shl (zext x), y)) -> (shl (zext x), (zext y))
3281 if ((N0.getOpcode() == ISD::SHL || N0.getOpcode() == ISD::SRL) &&
3282 N0.getOperand(0).getOpcode() == ISD::ZERO_EXTEND &&
3283 N0.hasOneUse()) {
3284 DebugLoc dl = N->getDebugLoc();
3285 return DAG.getNode(N0.getOpcode(), dl, VT,
3286 DAG.getNode(ISD::ZERO_EXTEND, dl, VT, N0.getOperand(0)),
3287 DAG.getNode(ISD::ZERO_EXTEND, dl, VT, N0.getOperand(1)));
3288 }
3289
32803290 return SDValue();
32813291 }
32823292
0 ; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s
1
2 define zeroext i16 @t1(i16 zeroext %x) nounwind readnone ssp {
3 entry:
4 ; CHECK: t1:
5 ; CHECK: seta %al
6 ; CHECK: movzbl %al, %eax
7 ; CHECK: shll $5, %eax
8 %0 = icmp ugt i16 %x, 26 ; [#uses=1]
9 %iftmp.1.0 = select i1 %0, i16 32, i16 0 ; [#uses=1]
10 ret i16 %iftmp.1.0
11 }
12
0 ; RUN: llc < %s -march=x86 | FileCheck %s
1
2 define i32 @t1(i8 zeroext %x) nounwind readnone ssp {
3 entry:
4 ; CHECK: t1:
5 ; CHECK: shll
6 ; CHECK-NOT: movzwl
7 ; CHECK: ret
8 %0 = zext i8 %x to i16
9 %1 = shl i16 %0, 5
10 %2 = zext i16 %1 to i32
11 ret i32 %2
12 }
13
14 define i32 @t2(i8 zeroext %x) nounwind readnone ssp {
15 entry:
16 ; CHECK: t2:
17 ; CHECK: shrl
18 ; CHECK-NOT: movzwl
19 ; CHECK: ret
20 %0 = zext i8 %x to i16
21 %1 = lshr i16 %0, 3
22 %2 = zext i16 %1 to i32
23 ret i32 %2
24 }
25
26 define i32 @t3(i8 zeroext %x, i8 zeroext %y) nounwind readnone ssp {
27 entry:
28 ; CHECK: t3:
29 ; CHECK: shll
30 ; CHECK-NOT: movzwl
31 ; CHECK: ret
32 %0 = zext i8 %x to i16
33 %1 = zext i8 %y to i16
34 %2 = shl i16 %0, %1
35 %3 = zext i16 %2 to i32
36 ret i32 %3
37 }