@@ -3255,24 +3255,18 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
3255
3255
if (!RK || RK.AttrKind != Attribute::Alignment ||
3256
3256
!isPowerOf2_64 (RK.ArgValue ))
3257
3257
continue ;
3258
- auto *C = dyn_cast<Constant>(RK.WasOn );
3259
- if (C && C->isNullValue ()) {
3260
- } else {
3261
- Value *UO = getUnderlyingObject (RK.WasOn );
3262
- if (!UO || isa<Argument>(UO))
3263
- continue ;
3264
-
3265
- // Try to get the instruction before the assumption to use as
3266
- // context.
3267
- Instruction *CtxI = nullptr ;
3268
- if (CtxI && II->getParent ()->begin () != II->getIterator ())
3269
- CtxI = II->getPrevNode ();
3270
-
3271
- auto Known = computeKnownBits (RK.WasOn , 1 , CtxI);
3272
- unsigned KnownAlign = 1 << Known.countMinTrailingZeros ();
3273
- if (KnownAlign < RK.ArgValue )
3274
- continue ;
3275
- }
3258
+
3259
+ // Don't try to remove align assumptions for pointers derived from
3260
+ // arguments. We might lose information if the function gets inline and
3261
+ // the align argument attribute disappears.
3262
+ Value *UO = getUnderlyingObject (RK.WasOn );
3263
+ if (!UO || isa<Argument>(UO))
3264
+ continue ;
3265
+
3266
+ auto Known = computeKnownBits (RK.WasOn , 0 , nullptr );
3267
+ unsigned KnownAlign = 1 << Known.countMinTrailingZeros ();
3268
+ if (KnownAlign < RK.ArgValue )
3269
+ continue ;
3276
3270
auto *New = CallBase::removeOperandBundle (II, OBU.getTagID ());
3277
3271
return New;
3278
3272
}
0 commit comments