Value simplification result in AAValueSimplify is sometimes flow-sensitive because of AAConstantRange::getConstantRangeFromLVI,AAConstantRange::getConstantRangeFromSCEV.
But manifestation for callsite argument is done in the same way for the floating position. This causes the following unexpected simplification, for example.
Before:
define i32 @g(i1 %d) {
br i1 %c, label %t, label %f
t:
%ret1 = call i32 @f(i1 %c)
ret i32 %ret1
f:
%ret2 = call i32 @f(i1 false)
ret i32 %ret2
}After:
define i32 @g(i1 %d) {
br label %t
t:
%ret1 = call i32 @f(i1 true)
ret i32 %ret1
f:
%ret2 = call i32 @f(i1 false)
ret i32 %ret2
}This patch fix the problem by replacing use with simplified values in manifestation.
Move the U into the conditional or make if (!C) return an early exit.