The [(CastII (AddI x const)) -> (AddI (CastII x) const) transformation change block in CastIINode::Ideal() - castnode.cpp] was earlier added as part of old JDK-8145322 enhancement fix. ("Code generated from unsafe loops can be slightly improved")
But in later reported JDK-8165661, found that the 8145322 part changes causing performance regression for x86_64. So the same got reverted for JDK-8165661 fix.
Creating this new enhancement CR to investigate issues with OLD 8145322 changes and for a possible better version of the same.