Follow-up to D122933.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | ||
---|---|---|
8823–8826 | Do we have any tests where RHS is a constant, but not a simm12 and needs to be placed in a register. Would also be good to test cases where the setcc result is used by a branch. Even a simm12 would need to be put in a register for that case. |
It's not clear to my why preferring a comparison involving RHS over one involving LHS is generally profitable just because RHS happens to be a constant. Correct me if I'm wrong, but nothing has ensured that RHS is a small constant has it? Meaning, we may have to materialize it into a register and pay the same cost as the LHS based compare? By using RHS, we loose the ability to do CSE of repeated uadds.
I think you want some predicate to check that the comparison can fold into an immediate form at the minimum.
I'm new to this area, so I may simply be missing something here.
llvm/test/CodeGen/RISCV/xaluo.ll | ||
---|---|---|
4227 | This is materializing a constant in a register which we didn't need to do before. Looking at the generated code before this patch, there was a move instruction, but I think that was because of register allocation constraints from above and below. If we change the test to this, then this patch increases instructions. define i64 @uaddo.i64.constant_setcc_on_overflow_flag(i64* %p) { entry: %v1 = load i64, i64* %p %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %v1, i64 2) %val = extractvalue {i64, i1} %t, 0 %obit = extractvalue {i64, i1} %t, 1 br i1 %obit, label %IfOverflow, label %IfNoOverflow IfOverflow: ret i64 0 IfNoOverflow: ret i64 %val } |
llvm/test/CodeGen/RISCV/xaluo.ll | ||
---|---|---|
4227 | Indeed, this patch increases instructions in this case. I have to think about it. |
Kind of late now, but I didn't notice the title wasn't updated. So it doesn't match the contents of the patch.
"necessary benefits" -> "necessarily beneficial"