[llvm] [SCEV] Simplify SCEVExpr for PHI to SCEV for operand if operands are identical (PR #115945)

Akshay Deodhar via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 3 04:21:53 PST 2024


akshayrdeodhar wrote:

Looked into this- this is expected behaviour, I think we should ignore this regression. `%indvars.iv` is created by IndVarSimplify, by widening `%srcIndex.03`. 

Here's the debug output of that pass, for the changed version of the compiler:
`Wide IV:   %indvars.iv = phi i64 [ %indvars.iv.next, %while.cond.backedge ], [ %0, %while.body.preheader ]
INDVARS: eliminating   %idxprom = sext i32 %srcIndex.03 to i64 replaced by   %indvars.iv = phi i64 [ %indvars.iv.next, %while.cond.backedge ], [ %0, %while.body.preheader ]
Cloning arithmetic IVUser:   %inc = add nsw i32 %srcIndex.03, 1
INDVARS: Truncate IV   %3 = add nsw i64 %indvars.iv, 1 for user   %srcIndex.0.be = phi i32 [ %inc, %if.then3 ], [ %inc33, %if.else15 ]
INDVARS: Widen lcssa phi   %inc.lcssa = phi i32 [ %inc, %if.then3 ] to   %inc.lcssa.wide = phi i64 [ %3, %if.then3 ]
Cloning arithmetic IVUser:   %inc33 = add nsw i32 %srcIndex.03, 1`

Before the change, the compiler fails to do IV widening. 

This is because the new compiler is able to create an AddRecExpr for %srcIndex.03, as it is able to simplify `%srcIndex.0.be = phi i32 [ %inc, %if.then3 ], [ %inc33, %if.else15 ]`, while the old compiler cannot. 

https://github.com/llvm/llvm-project/pull/115945


More information about the llvm-commits mailing list