mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-09 12:04:02 +00:00
Revert "Address Duncan's CR request:"
This reverts commit 20a05be15ea5271ab6185b83200fa88263362400. (svn rev 138340) Conflicts: test/Transforms/InstCombine/bitcast.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138366 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
99e84e07ff
commit
acc8f2d938
@ -51,9 +51,6 @@ public:
|
|||||||
/// isNullValue - Return true if this is the value that would be returned by
|
/// isNullValue - Return true if this is the value that would be returned by
|
||||||
/// getNullValue.
|
/// getNullValue.
|
||||||
bool isNullValue() const;
|
bool isNullValue() const;
|
||||||
/// isAllOnesValue - Return true if this is the value that would be returned by
|
|
||||||
/// getAllOnesValue.
|
|
||||||
bool isAllOnesValue() const;
|
|
||||||
|
|
||||||
/// isNegativeZeroValue - Return true if the value is what would be returned
|
/// isNegativeZeroValue - Return true if the value is what would be returned
|
||||||
/// by getZeroValueForNegation.
|
/// by getZeroValueForNegation.
|
||||||
|
@ -45,9 +45,15 @@ using namespace llvm;
|
|||||||
/// ConstantExpr if unfoldable.
|
/// ConstantExpr if unfoldable.
|
||||||
static Constant *FoldBitCast(Constant *C, Type *DestTy,
|
static Constant *FoldBitCast(Constant *C, Type *DestTy,
|
||||||
const TargetData &TD) {
|
const TargetData &TD) {
|
||||||
// Catch the obvious splat cases.
|
|
||||||
if (C->isNullValue()) return Constant::getNullValue(DestTy);
|
ConstantVector *CV = dyn_cast<ConstantVector>(C);
|
||||||
if (C->isAllOnesValue()) return Constant::getAllOnesValue(DestTy);
|
IntegerType *IntVTy = dyn_cast<IntegerType>(DestTy);
|
||||||
|
// When casting vectors to scalar integers, catch the
|
||||||
|
// obvious splat cases.
|
||||||
|
if (IntVTy && CV) {
|
||||||
|
if (CV->isNullValue()) return ConstantInt::getNullValue(IntVTy);
|
||||||
|
if (CV->isAllOnesValue()) return ConstantInt::getAllOnesValue(IntVTy);
|
||||||
|
}
|
||||||
|
|
||||||
// The code below only handles casts to vectors currently.
|
// The code below only handles casts to vectors currently.
|
||||||
VectorType *DestVTy = dyn_cast<VectorType>(DestTy);
|
VectorType *DestVTy = dyn_cast<VectorType>(DestTy);
|
||||||
@ -62,7 +68,6 @@ static Constant *FoldBitCast(Constant *C, Type *DestTy,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If this is a bitcast from constant vector -> vector, fold it.
|
// If this is a bitcast from constant vector -> vector, fold it.
|
||||||
ConstantVector *CV = dyn_cast<ConstantVector>(C);
|
|
||||||
if (CV == 0)
|
if (CV == 0)
|
||||||
return ConstantExpr::getBitCast(C, DestTy);
|
return ConstantExpr::getBitCast(C, DestTy);
|
||||||
|
|
||||||
|
@ -62,21 +62,6 @@ bool Constant::isNullValue() const {
|
|||||||
return isa<ConstantAggregateZero>(this) || isa<ConstantPointerNull>(this);
|
return isa<ConstantAggregateZero>(this) || isa<ConstantPointerNull>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Constant::isAllOnesValue() const {
|
|
||||||
// Check for -1 integers
|
|
||||||
if (const ConstantInt *CI = dyn_cast<ConstantInt>(this))
|
|
||||||
return CI->isAllOnesValue();
|
|
||||||
|
|
||||||
// +0.0 is null.
|
|
||||||
if (const ConstantFP *CFP = dyn_cast<ConstantFP>(this))
|
|
||||||
return CFP->getValueAPF().bitcastToAPInt().isAllOnesValue();
|
|
||||||
|
|
||||||
// Check for constant vectors
|
|
||||||
if (const ConstantVector *CV = dyn_cast<ConstantVector>(this))
|
|
||||||
return CV->isAllOnesValue();
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Constructor to create a '0' constant of arbitrary type...
|
// Constructor to create a '0' constant of arbitrary type...
|
||||||
Constant *Constant::getNullValue(Type *Ty) {
|
Constant *Constant::getNullValue(Type *Ty) {
|
||||||
switch (Ty->getTypeID()) {
|
switch (Ty->getTypeID()) {
|
||||||
@ -141,7 +126,7 @@ Constant *Constant::getAllOnesValue(Type *Ty) {
|
|||||||
SmallVector<Constant*, 16> Elts;
|
SmallVector<Constant*, 16> Elts;
|
||||||
VectorType *VTy = cast<VectorType>(Ty);
|
VectorType *VTy = cast<VectorType>(Ty);
|
||||||
Elts.resize(VTy->getNumElements(), getAllOnesValue(VTy->getElementType()));
|
Elts.resize(VTy->getNumElements(), getAllOnesValue(VTy->getElementType()));
|
||||||
assert(Elts[0] && "Invalid AllOnes value!");
|
assert(Elts[0] && "Not a vector integer type!");
|
||||||
return cast<ConstantVector>(ConstantVector::get(Elts));
|
return cast<ConstantVector>(ConstantVector::get(Elts));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1079,16 +1064,13 @@ bool ConstantVector::isAllOnesValue() const {
|
|||||||
// Check out first element.
|
// Check out first element.
|
||||||
const Constant *Elt = getOperand(0);
|
const Constant *Elt = getOperand(0);
|
||||||
const ConstantInt *CI = dyn_cast<ConstantInt>(Elt);
|
const ConstantInt *CI = dyn_cast<ConstantInt>(Elt);
|
||||||
const ConstantFP *CF = dyn_cast<ConstantFP>(Elt);
|
if (!CI || !CI->isAllOnesValue()) return false;
|
||||||
|
|
||||||
// Then make sure all remaining elements point to the same value.
|
// Then make sure all remaining elements point to the same value.
|
||||||
for (unsigned I = 1, E = getNumOperands(); I < E; ++I)
|
for (unsigned I = 1, E = getNumOperands(); I < E; ++I)
|
||||||
if (getOperand(I) != Elt)
|
if (getOperand(I) != Elt)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// First value is all-ones.
|
return true;
|
||||||
return (CI && CI->isAllOnesValue()) ||
|
|
||||||
(CF && CF->isAllOnesValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getSplatValue - If this is a splat constant, where all of the
|
/// getSplatValue - If this is a splat constant, where all of the
|
||||||
|
@ -11,7 +11,7 @@ define i32 @test1(i64 %a) {
|
|||||||
%t3 = xor <2 x i32> %t1, %t2
|
%t3 = xor <2 x i32> %t1, %t2
|
||||||
%t4 = extractelement <2 x i32> %t3, i32 0
|
%t4 = extractelement <2 x i32> %t3, i32 0
|
||||||
ret i32 %t4
|
ret i32 %t4
|
||||||
|
|
||||||
; CHECK: @test1
|
; CHECK: @test1
|
||||||
; CHECK: ret i32 0
|
; CHECK: ret i32 0
|
||||||
}
|
}
|
||||||
@ -30,7 +30,7 @@ define float @test2(<2 x float> %A, <2 x i32> %B) {
|
|||||||
|
|
||||||
%add = fadd float %tmp24, %tmp4
|
%add = fadd float %tmp24, %tmp4
|
||||||
ret float %add
|
ret float %add
|
||||||
|
|
||||||
; CHECK: @test2
|
; CHECK: @test2
|
||||||
; CHECK-NEXT: %tmp24 = extractelement <2 x float> %A, i32 0
|
; CHECK-NEXT: %tmp24 = extractelement <2 x float> %A, i32 0
|
||||||
; CHECK-NEXT: bitcast <2 x i32> %B to <2 x float>
|
; CHECK-NEXT: bitcast <2 x i32> %B to <2 x float>
|
||||||
@ -55,7 +55,7 @@ define float @test3(<2 x float> %A, <2 x i64> %B) {
|
|||||||
|
|
||||||
%add = fadd float %tmp24, %tmp4
|
%add = fadd float %tmp24, %tmp4
|
||||||
ret float %add
|
ret float %add
|
||||||
|
|
||||||
; CHECK: @test3
|
; CHECK: @test3
|
||||||
; CHECK-NEXT: %tmp24 = extractelement <2 x float> %A, i32 1
|
; CHECK-NEXT: %tmp24 = extractelement <2 x float> %A, i32 1
|
||||||
; CHECK-NEXT: bitcast <2 x i64> %B to <4 x float>
|
; CHECK-NEXT: bitcast <2 x i64> %B to <4 x float>
|
||||||
@ -75,7 +75,7 @@ define <2 x i32> @test4(i32 %A, i32 %B){
|
|||||||
; CHECK: @test4
|
; CHECK: @test4
|
||||||
; CHECK-NEXT: insertelement <2 x i32> undef, i32 %A, i32 0
|
; CHECK-NEXT: insertelement <2 x i32> undef, i32 %A, i32 0
|
||||||
; CHECK-NEXT: insertelement <2 x i32> {{.*}}, i32 %B, i32 1
|
; CHECK-NEXT: insertelement <2 x i32> {{.*}}, i32 %B, i32 1
|
||||||
; CHECK-NEXT: ret <2 x i32>
|
; CHECK-NEXT: ret <2 x i32>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ define <2 x float> @test5(float %A, float %B) {
|
|||||||
; CHECK: @test5
|
; CHECK: @test5
|
||||||
; CHECK-NEXT: insertelement <2 x float> undef, float %A, i32 0
|
; CHECK-NEXT: insertelement <2 x float> undef, float %A, i32 0
|
||||||
; CHECK-NEXT: insertelement <2 x float> {{.*}}, float %B, i32 1
|
; CHECK-NEXT: insertelement <2 x float> {{.*}}, float %B, i32 1
|
||||||
; CHECK-NEXT: ret <2 x float>
|
; CHECK-NEXT: ret <2 x float>
|
||||||
}
|
}
|
||||||
|
|
||||||
define <2 x float> @test6(float %A){
|
define <2 x float> @test6(float %A){
|
||||||
@ -113,27 +113,3 @@ define i64 @ISPC0(i64 %in) {
|
|||||||
; CHECK: @ISPC0
|
; CHECK: @ISPC0
|
||||||
; CHECK: ret i64 0
|
; CHECK: ret i64 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
define i64 @Vec2(i64 %in) {
|
|
||||||
%out = and i64 %in, xor (i64 bitcast (<4 x i16> <i16 0, i16 0, i16 0, i16 0> to i64), i64 0)
|
|
||||||
ret i64 %out
|
|
||||||
; CHECK: @Vec2
|
|
||||||
; CHECK: ret i64 0
|
|
||||||
}
|
|
||||||
|
|
||||||
define i64 @All11(i64 %in) {
|
|
||||||
%out = and i64 %in, xor (i64 bitcast (<2 x float> bitcast (i64 -1 to <2 x float>) to i64), i64 -1)
|
|
||||||
ret i64 %out
|
|
||||||
; CHECK: @All11
|
|
||||||
; CHECK: ret i64 0
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
define i32 @All111(i32 %in) {
|
|
||||||
%out = and i32 %in, xor (i32 bitcast (<1 x float> bitcast (i32 -1 to <1 x float>) to i32), i32 -1)
|
|
||||||
ret i32 %out
|
|
||||||
; CHECK: @All111
|
|
||||||
; CHECK: ret i32 0
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user