@@ -64,7 +64,7 @@ bool UnrolledInstAnalyzer::simplifyInstWithSCEV(Instruction *I) {
64
64
return false ;
65
65
SimplifiedAddress Address;
66
66
Address.Base = Base->getValue ();
67
- Address.Offset = Offset->getValue ();
67
+ Address.Offset = Offset->getAPInt ();
68
68
SimplifiedAddresses[I] = Address;
69
69
return false ;
70
70
}
@@ -105,7 +105,7 @@ bool UnrolledInstAnalyzer::visitLoad(LoadInst &I) {
105
105
auto AddressIt = SimplifiedAddresses.find (AddrOp);
106
106
if (AddressIt == SimplifiedAddresses.end ())
107
107
return false ;
108
- ConstantInt * SimplifiedAddrOp = AddressIt->second .Offset ;
108
+ const APInt & SimplifiedAddrOp = AddressIt->second .Offset ;
109
109
110
110
auto *GV = dyn_cast<GlobalVariable>(AddressIt->second .Base );
111
111
// We're only interested in loads that can be completely folded to a
@@ -125,9 +125,9 @@ bool UnrolledInstAnalyzer::visitLoad(LoadInst &I) {
125
125
return false ;
126
126
127
127
unsigned ElemSize = CDS->getElementType ()->getPrimitiveSizeInBits () / 8U ;
128
- if (SimplifiedAddrOp-> getValue () .getActiveBits () > 64 )
128
+ if (SimplifiedAddrOp.getActiveBits () > 64 )
129
129
return false ;
130
- int64_t SimplifiedAddrOpV = SimplifiedAddrOp-> getSExtValue ();
130
+ int64_t SimplifiedAddrOpV = SimplifiedAddrOp. getSExtValue ();
131
131
if (SimplifiedAddrOpV < 0 ) {
132
132
// FIXME: For now we conservatively ignore out of bound accesses, but
133
133
// we're allowed to perform the optimization in this case.
@@ -186,10 +186,9 @@ bool UnrolledInstAnalyzer::visitCmpInst(CmpInst &I) {
186
186
if (SimplifiedRHS != SimplifiedAddresses.end ()) {
187
187
SimplifiedAddress &LHSAddr = SimplifiedLHS->second ;
188
188
SimplifiedAddress &RHSAddr = SimplifiedRHS->second ;
189
- if (LHSAddr.Base == RHSAddr.Base ) {
190
- LHS = LHSAddr.Offset ;
191
- RHS = RHSAddr.Offset ;
192
- }
189
+ if (LHSAddr.Base == RHSAddr.Base )
190
+ return ICmpInst::compare (LHSAddr.Offset , RHSAddr.Offset ,
191
+ I.getPredicate ());
193
192
}
194
193
}
195
194
}
0 commit comments