[llvm-commits] [127734] simplify code by factoring it a bit better.
clattner at apple.com
clattner at apple.com
Sun May 27 08:33:18 PDT 2007
Revision: 127734
Author: clattner
Date: 2007-05-27 08:33:17 -0700 (Sun, 27 May 2007)
Log Message:
-----------
simplify code by factoring it a bit better.
Modified Paths:
--------------
apple-local/branches/llvm/gcc/config/i386/llvm-i386.cpp
Modified: apple-local/branches/llvm/gcc/config/i386/llvm-i386.cpp
===================================================================
--- apple-local/branches/llvm/gcc/config/i386/llvm-i386.cpp
2007-05-27 15:27:26 UTC (rev 127733)
+++ apple-local/branches/llvm/gcc/config/i386/llvm-i386.cpp
2007-05-27 15:33:17 UTC (rev 127734)
@@ -241,11 +241,13 @@
case IX86_BUILTIN_XORPD:
case IX86_BUILTIN_ANDNPD:
if (cast<VectorType>(ResultType)->getNumElements() == 4) // v4f32
- Ops[0] = new BitCastInst(Ops[0], VectorType::get
(Type::Int32Ty, 4),"tmp");
+ Ops[0] = Builder.CreateBitCast(Ops[0], VectorType::get
(Type::Int32Ty, 4),
+ "tmp");
else // v2f64
- Ops[0] = new BitCastInst(Ops[0], VectorType::get
(Type::Int64Ty, 2),"tmp");
+ Ops[0] = Builder.CreateBitCast(Ops[0], VectorType::get
(Type::Int64Ty, 2),
+ "tmp");
- Ops[1] = new BitCastInst(Ops[1], Ops[0]->getType(), "tmp");
+ Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType(), "tmp");
switch (FnCode) {
case IX86_BUILTIN_ANDPS:
Result = Builder.CreateAnd(Ops[0], Ops[1], "tmp");
@@ -496,33 +498,19 @@
case IX86_BUILTIN_CMPUNORDSS: {
Function *cmpss =
Intrinsic::getDeclaration(TheModule, Intrinsic::x86_sse_cmp_ss);
- Value *Pred = 0;
+ unsigned PredCode;
switch (FnCode) {
- case IX86_BUILTIN_CMPEQSS:
- Pred = ConstantInt::get(Type::Int8Ty, 0);
- break;
- case IX86_BUILTIN_CMPLTSS:
- Pred = ConstantInt::get(Type::Int8Ty, 1);
- break;
- case IX86_BUILTIN_CMPLESS:
- Pred = ConstantInt::get(Type::Int8Ty, 2);
- break;
- case IX86_BUILTIN_CMPUNORDSS:
- Pred = ConstantInt::get(Type::Int8Ty, 3);
- break;
- case IX86_BUILTIN_CMPNEQSS:
- Pred = ConstantInt::get(Type::Int8Ty, 4);
- break;
- case IX86_BUILTIN_CMPNLTSS:
- Pred = ConstantInt::get(Type::Int8Ty, 5);
- break;
- case IX86_BUILTIN_CMPNLESS:
- Pred = ConstantInt::get(Type::Int8Ty, 6);
- break;
- case IX86_BUILTIN_CMPORDSS:
- Pred = ConstantInt::get(Type::Int8Ty, 7);
- break;
+ default: assert(0 && "Unknown fncode");
+ case IX86_BUILTIN_CMPEQSS: PredCode = 0; break;
+ case IX86_BUILTIN_CMPLTSS: PredCode = 1; break;
+ case IX86_BUILTIN_CMPLESS: PredCode = 2; break;
+ case IX86_BUILTIN_CMPUNORDSS: PredCode = 3; break;
+ case IX86_BUILTIN_CMPNEQSS: PredCode = 4; break;
+ case IX86_BUILTIN_CMPNLTSS: PredCode = 5; break;
+ case IX86_BUILTIN_CMPNLESS: PredCode = 6; break;
+ case IX86_BUILTIN_CMPORDSS: PredCode = 7; break;
}
+ Value *Pred = ConstantInt::get(Type::Int8Ty, PredCode);
Value *CallOps[3] = { Ops[0], Ops[1], Pred };
Result = Builder.CreateCall(cmpss, CallOps, 3, "tmp");
Result = Builder.CreateBitCast(Result, ResultType, "tmp");
@@ -543,49 +531,23 @@
Function *cmppd =
Intrinsic::getDeclaration(TheModule,
Intrinsic::x86_sse2_cmp_pd);
bool flip = false;
- Value *Pred = 0;
+ unsigned PredCode;
switch (FnCode) {
- case IX86_BUILTIN_CMPEQPD:
- Pred = ConstantInt::get(Type::Int8Ty, 0);
- break;
- case IX86_BUILTIN_CMPLTPD:
- Pred = ConstantInt::get(Type::Int8Ty, 1);
- break;
- case IX86_BUILTIN_CMPGTPD:
- Pred = ConstantInt::get(Type::Int8Ty, 1);
- flip = true;
- break;
- case IX86_BUILTIN_CMPLEPD:
- Pred = ConstantInt::get(Type::Int8Ty, 2);
- break;
- case IX86_BUILTIN_CMPGEPD:
- Pred = ConstantInt::get(Type::Int8Ty, 2);
- flip = true;
- break;
- case IX86_BUILTIN_CMPUNORDPD:
- Pred = ConstantInt::get(Type::Int8Ty, 3);
- break;
- case IX86_BUILTIN_CMPNEQPD:
- Pred = ConstantInt::get(Type::Int8Ty, 4);
- break;
- case IX86_BUILTIN_CMPNLTPD:
- Pred = ConstantInt::get(Type::Int8Ty, 5);
- break;
- case IX86_BUILTIN_CMPNGTPD:
- Pred = ConstantInt::get(Type::Int8Ty, 5);
- flip = true;
- break;
- case IX86_BUILTIN_CMPNLEPD:
- Pred = ConstantInt::get(Type::Int8Ty, 6);
- break;
- case IX86_BUILTIN_CMPNGEPD:
- Pred = ConstantInt::get(Type::Int8Ty, 6);
- flip = true;
- break;
- case IX86_BUILTIN_CMPORDPD:
- Pred = ConstantInt::get(Type::Int8Ty, 7);
- break;
+ default: assert(0 && "Unknown fncode!");
+ case IX86_BUILTIN_CMPEQPD: PredCode = 0; break;
+ case IX86_BUILTIN_CMPLTPD: PredCode = 1; break;
+ case IX86_BUILTIN_CMPGTPD: PredCode = 1; flip = true; break;
+ case IX86_BUILTIN_CMPLEPD: PredCode = 2; break;
+ case IX86_BUILTIN_CMPGEPD: PredCode = 2; flip = true; break;
+ case IX86_BUILTIN_CMPUNORDPD: PredCode = 3; break;
+ case IX86_BUILTIN_CMPNEQPD: PredCode = 4; break;
+ case IX86_BUILTIN_CMPNLTPD: PredCode = 5; break;
+ case IX86_BUILTIN_CMPNGTPD: PredCode = 5; flip = true; break;
+ case IX86_BUILTIN_CMPNLEPD: PredCode = 6; break;
+ case IX86_BUILTIN_CMPNGEPD: PredCode = 6; flip = true; break;
+ case IX86_BUILTIN_CMPORDPD: PredCode = 7; break;
}
+ Value *Pred = ConstantInt::get(Type::Int8Ty, PredCode);
Value *Arg0 = Ops[0];
Value *Arg1 = Ops[1];
if (flip) std::swap(Arg0, Arg1);
@@ -605,37 +567,20 @@
case IX86_BUILTIN_CMPUNORDSD: {
Function *cmpsd =
Intrinsic::getDeclaration(TheModule,
Intrinsic::x86_sse2_cmp_sd);
- Value *Pred = 0;
+ unsigned PredCode;
switch (FnCode) {
- case IX86_BUILTIN_CMPEQSD:
- Pred = ConstantInt::get(Type::Int8Ty, 0);
- break;
- case IX86_BUILTIN_CMPLTSD:
- Pred = ConstantInt::get(Type::Int8Ty, 1);
- break;
- case IX86_BUILTIN_CMPLESD:
- Pred = ConstantInt::get(Type::Int8Ty, 2);
- break;
- case IX86_BUILTIN_CMPUNORDSD:
- Pred = ConstantInt::get(Type::Int8Ty, 3);
- break;
- case IX86_BUILTIN_CMPNEQSD:
- Pred = ConstantInt::get(Type::Int8Ty, 4);
- break;
- case IX86_BUILTIN_CMPNLTSD:
- Pred = ConstantInt::get(Type::Int8Ty, 5);
- break;
- case IX86_BUILTIN_CMPNLESD:
- Pred = ConstantInt::get(Type::Int8Ty, 6);
- break;
- case IX86_BUILTIN_CMPORDSD:
- Pred = ConstantInt::get(Type::Int8Ty, 7);
- break;
+ default: assert(0 && "Unknown fncode");
+ case IX86_BUILTIN_CMPEQSD: PredCode = 0; break;
+ case IX86_BUILTIN_CMPLTSD: PredCode = 1; break;
+ case IX86_BUILTIN_CMPLESD: PredCode = 2; break;
+ case IX86_BUILTIN_CMPUNORDSD: PredCode = 3; break;
+ case IX86_BUILTIN_CMPNEQSD: PredCode = 4; break;
+ case IX86_BUILTIN_CMPNLTSD: PredCode = 5; break;
+ case IX86_BUILTIN_CMPNLESD: PredCode = 6; break;
+ case IX86_BUILTIN_CMPORDSD: PredCode = 7; break;
}
-
- Value *Arg0 = Ops[0];
- Value *Arg1 = Ops[1];
- Value *CallOps[3] = { Arg0, Arg1, Pred };
+ Value *Pred = ConstantInt::get(Type::Int8Ty, PredCode);
+ Value *CallOps[3] = { Ops[0], Ops[1], Pred };
Result = Builder.CreateCall(cmpsd, CallOps, 3, "tmp");
Result = Builder.CreateBitCast(Result, ResultType, "tmp");
return true;
More information about the llvm-commits
mailing list