Details
- Reviewers
nikic - Commits
- rGe549d578cc2d: [InstCombine] Test cases for D155718
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/test/Transforms/InstCombine/icmp-fold-into-phi.ll | ||
---|---|---|
97 | This test looks too complicated for what we actually want to test. I think something like this should be sufficient: define i1 @test(i32 %x, i32 %y) { entry: switch i32 %x, label %bb1 [ i32 0, label %bb2 i32 1, label %bb3 ] bb1: br label %bb2 bb2: %phi1 = phi i32 [ 1, %entry ], [ %y, %bb1 ] br label %bb3 bb3: %phi2 = phi i32 [ %phi1, %bb2 ], [ 0, %entry ] %cmp = icmp ugt i32 %phi2, 1 ret i1 %cmp } This would also make it independent of D154064 and allow us to land this patch first. |
llvm/test/Transforms/InstCombine/icmp-fold-into-phi.ll | ||
---|---|---|
97 | Well, I guess it would make sense to also add your test to make sure that D154064 doesn't regress it, but in that case we should cut it down a bit. There's a lot of parts that aren't really relevant, e.g. the final block could be just this I think: %cond3 = phi i32 [ %cond2, %sw.bb ], [ 134, %cond.false2 ], [ 2, %cond.false ], [ 1, %entry ] %cmp = icmp ult i32 %cond3, 2 ret i1 %cmp |
llvm/test/Transforms/InstCombine/icmp-fold-into-phi.ll | ||
---|---|---|
97 | Hmm, I have added another version of this test which is simplified - I still feel that the original test highlights the fold more clearly :shrug: |
llvm/test/Transforms/InstCombine/icmp-fold-into-phi.ll | ||
---|---|---|
97 | Here is a simplified version of the original test: define i1 @test(i1 %c, i1 %c1, i1 %c2, i1 %c3, i1 %c4) { entry: br i1 %c, label %sw.epilog, label %cond.false cond.false: br i1 %c1, label %sw.epilog, label %cond.false2 cond.false2: br i1 %c2, label %sw.epilog, label %cond.false3 cond.false3: br i1 %c3, label %sw.bb, label %cond.end cond.end: %cond = select i1 %c4, i32 127, i32 126 br label %sw.bb sw.bb: %cond2 = phi i32 [ %cond, %cond.end ], [ 128, %cond.false3 ] br label %sw.epilog sw.epilog: %cond3 = phi i32 [ %cond2, %sw.bb ], [ 134, %cond.false2 ], [ 2, %cond.false ], [ 1, %entry ] %cmp = icmp ult i32 %cond3, 2 ret i1 %cmp } This just has the phi nodes and icmp necessary to perform the fold and omits all the function calls (and globals, and declarations needed for them). We're not aiming for realism here, but for something minimal that shows the change in behavior. |
This test looks too complicated for what we actually want to test. I think something like this should be sufficient:
This would also make it independent of D154064 and allow us to land this patch first.