mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-17 19:51:13 +00:00
[SCCP] Fold constants as we build them whne visiting cast instructions.
This should be slightly more efficient and could avoid spurious overdefined markings, as Eli pointed out. Differential Revision: http://reviews.llvm.org/D22122 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274905 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9ea0ae7891
commit
a5b3bc1479
@ -760,8 +760,10 @@ void SCCPSolver::visitCastInst(CastInst &I) {
|
||||
if (OpSt.isOverdefined()) // Inherit overdefinedness of operand
|
||||
markOverdefined(&I);
|
||||
else if (OpSt.isConstant()) {
|
||||
Constant *C =
|
||||
ConstantExpr::getCast(I.getOpcode(), OpSt.getConstant(), I.getType());
|
||||
// Fold the constant as we build.
|
||||
Constant *C = ConstantFoldCastOperand(
|
||||
I.getOpcode(), getValueState(I.getOperand(0)).getConstant(),
|
||||
I.getType(), DL);
|
||||
if (isa<UndefValue>(C))
|
||||
return;
|
||||
// Propagate constant value
|
||||
|
9
test/Transforms/SCCP/bitcast.ll
Normal file
9
test/Transforms/SCCP/bitcast.ll
Normal file
@ -0,0 +1,9 @@
|
||||
; RUN: opt < %s -ipsccp -S | FileCheck %s
|
||||
|
||||
define i128 @vector_to_int_cast() {
|
||||
%A = bitcast <4 x i32> <i32 1073741824, i32 1073741824, i32 1073741824, i32 1073741824> to i128
|
||||
ret i128 %A
|
||||
}
|
||||
|
||||
; CHECK: define i128 @vector_to_int_cast(
|
||||
; CHECK-NEXT: ret i128 85070591750041656499021422275829170176
|
Loading…
x
Reference in New Issue
Block a user