[llvm-commits] [llvm-gcc-4.2] r128510 - /llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp
Evan Cheng
evan.cheng at apple.com
Tue Mar 29 16:51:37 PDT 2011
Author: evancheng
Date: Tue Mar 29 18:51:37 2011
New Revision: 128510
URL: http://llvm.org/viewvc/llvm-project?rev=128510&view=rev
Log:
Lower __builtin_neon_vmull* etc. directly to llvm intrinsics
@llvm.arm.neon.vmulls and @llvm.arm.neon.vmullu.*. Also lower
__builtin_neon_vmlal*, __builtin_neon_vmlsl* etc. to the intrinsics plus an
add / sub instruction. This change ensures optimizer won't hoist the sext /
zext away from the mul instruction which would cause performance regression.
Second part of rdar://8832507, rdar://9203134
Modified:
llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp
Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp?rev=128510&r1=128509&r2=128510&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Tue Mar 29 18:51:37 2011
@@ -929,17 +929,16 @@
return UnexpectedError("%Hinvalid lane number", exp, Result);
Ops[2] = BuildDupLane(Ops[2], LaneVal, NUnits, Builder);
}
- if (datatype == neon_datatype_signed) {
- Ops[1] = Builder.CreateSExt(Ops[1], ResultType);
- Ops[2] = Builder.CreateSExt(Ops[2], ResultType);
- } else if (datatype == neon_datatype_unsigned) {
- Ops[1] = Builder.CreateZExt(Ops[1], ResultType);
- Ops[2] = Builder.CreateZExt(Ops[2], ResultType);
- } else
+ if (datatype == neon_datatype_signed)
+ intID = Intrinsic::arm_neon_vmulls;
+ else if (datatype == neon_datatype_unsigned)
+ intID = Intrinsic::arm_neon_vmullu;
+ else
return BadImmediateError(exp, Result);
- Ops[1] = Builder.CreateMul(Ops[1], Ops[2]);
- Result = Builder.CreateAdd(Ops[0], Ops[1]);
+ intFn = Intrinsic::getDeclaration(TheModule, intID, &ResultType, 1);
+ Result = Builder.CreateCall2(intFn, Ops[1], Ops[2]);
+ Result = Builder.CreateAdd(Ops[0], Result);
break;
case NEON_BUILTIN_vmlsl_lane:
@@ -954,17 +953,16 @@
return UnexpectedError("%Hinvalid lane number", exp, Result);
Ops[2] = BuildDupLane(Ops[2], LaneVal, NUnits, Builder);
}
- if (datatype == neon_datatype_signed) {
- Ops[1] = Builder.CreateSExt(Ops[1], ResultType);
- Ops[2] = Builder.CreateSExt(Ops[2], ResultType);
- } else if (datatype == neon_datatype_unsigned) {
- Ops[1] = Builder.CreateZExt(Ops[1], ResultType);
- Ops[2] = Builder.CreateZExt(Ops[2], ResultType);
- } else
+ if (datatype == neon_datatype_signed)
+ intID = Intrinsic::arm_neon_vmulls;
+ else if (datatype == neon_datatype_unsigned)
+ intID = Intrinsic::arm_neon_vmullu;
+ else
return BadImmediateError(exp, Result);
- Ops[1] = Builder.CreateMul(Ops[1], Ops[2]);
- Result = Builder.CreateSub(Ops[0], Ops[1]);
+ intFn = Intrinsic::getDeclaration(TheModule, intID, &ResultType, 1);
+ Result = Builder.CreateCall2(intFn, Ops[1], Ops[2]);
+ Result = Builder.CreateSub(Ops[0], Result);
break;
case NEON_BUILTIN_vqdmulh_lane:
@@ -1044,22 +1042,17 @@
return UnexpectedError("%Hinvalid lane number", exp, Result);
Ops[1] = BuildDupLane(Ops[1], LaneVal, NUnits, Builder);
}
- if (datatype == neon_datatype_polynomial) {
+ if (datatype == neon_datatype_polynomial)
intID = Intrinsic::arm_neon_vmullp;
- intFn = Intrinsic::getDeclaration(TheModule, intID, &ResultType, 1);
- Result = Builder.CreateCall2(intFn, Ops[0], Ops[1]);
- break;
- }
- if (datatype == neon_datatype_signed) {
- Ops[0] = Builder.CreateSExt(Ops[0], ResultType);
- Ops[1] = Builder.CreateSExt(Ops[1], ResultType);
- } else if (datatype == neon_datatype_unsigned) {
- Ops[0] = Builder.CreateZExt(Ops[0], ResultType);
- Ops[1] = Builder.CreateZExt(Ops[1], ResultType);
- } else
+ else if (datatype == neon_datatype_signed)
+ intID = Intrinsic::arm_neon_vmulls;
+ else if (datatype == neon_datatype_unsigned)
+ intID = Intrinsic::arm_neon_vmullu;
+ else
return BadImmediateError(exp, Result);
- Result = Builder.CreateMul(Ops[0], Ops[1]);
+ intFn = Intrinsic::getDeclaration(TheModule, intID, &ResultType, 1);
+ Result = Builder.CreateCall2(intFn, Ops[0], Ops[1]);
break;
case NEON_BUILTIN_vqdmull_n:
More information about the llvm-commits
mailing list