llvm.org GIT mirror llvm / 5ae1da9
Minor optimization. sign-ext/anyext of undef is still undef. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127598 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 8 years ago
3 changed file(s) with 23 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
24812481 "Vector element count mismatch!");
24822482 if (OpOpcode == ISD::SIGN_EXTEND || OpOpcode == ISD::ZERO_EXTEND)
24832483 return getNode(OpOpcode, DL, VT, Operand.getNode()->getOperand(0));
2484 else if (OpOpcode == ISD::UNDEF)
2485 return getUNDEF(VT);
24842486 break;
24852487 case ISD::ZERO_EXTEND:
24862488 assert(VT.isInteger() && Operand.getValueType().isInteger() &&
25112513 OpOpcode == ISD::ANY_EXTEND)
25122514 // (ext (zext x)) -> (zext x) and (ext (sext x)) -> (sext x)
25132515 return getNode(OpOpcode, DL, VT, Operand.getNode()->getOperand(0));
2516 else if (OpOpcode == ISD::UNDEF)
2517 return getUNDEF(VT);
25142518
25152519 // (ext (trunx x)) -> x
25162520 if (OpOpcode == ISD::TRUNCATE) {
5050
5151 declare i8* @malloc(...)
5252
53 define fastcc void @test4() nounwind {
53 define fastcc void @test4(i16 %addr) nounwind {
5454 entry:
5555 ; A8: test4:
56 ; A8: ldr r1, [r0, r0, lsl #2]
57 ; A8: str r1, [r0, r0, lsl #2]
56 ; A8: ldr r2, [r0, r1, lsl #2]
57 ; A8: str r2, [r0, r1, lsl #2]
5858
5959 ; A9: test4:
60 ; A9: add r0, r0, r0, lsl #2
60 ; A9: add r0, r0, r4, lsl #2
6161 ; A9: ldr r1, [r0]
6262 ; A9: str r1, [r0]
6363 %0 = tail call i8* (...)* @malloc(i32 undef) nounwind
6464 %1 = bitcast i8* %0 to i32*
65 %2 = sext i16 undef to i32
65 %2 = sext i16 %addr to i32
6666 %3 = getelementptr inbounds i32* %1, i32 %2
6767 %4 = load i32* %3, align 4
6868 %5 = add nsw i32 %4, 1
0 ; RUN: llc < %s -mtriple=armv7-apple-darwin -mcpu=cortex-a8 | FileCheck %s
1
2 ; No need to sign-extend undef.
3
4 define i32 @t(i32* %a) nounwind {
5 entry:
6 ; CHECK: t:
7 ; CHECK: ldr r0, [r0]
8 ; CHECK: bx lr
9 %0 = sext i16 undef to i32
10 %1 = getelementptr inbounds i32* %a, i32 %0
11 %2 = load i32* %1, align 4
12 ret i32 %2
13 }