This fixes a regression introduced by D127115 in test/CodeGen/PowerPC/store-forward-be64.ll
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I'm a bit worried this will end up fighting the existing "(sext (truncate x)) -> (sextinreg x)" fold
Yes, it shouldn't in itself, but throw another transform in the loop, and it may well be.
Is there another approach you are thinking of? I thought about doing just (sext (sext_inreg (trunc x))) -> (sext (trunc x)) but that seemed too topical.
If you're after test cases: https://gcc.godbolt.org/z/dPzYvz6dW - you might want to look to see why this isn't helping
This is from x86/sdiv_fix.ll which is currently repeating sign extensions: https://github.com/llvm/llvm-project/blob/main/llvm/test/CodeGen/X86/sdiv_fix.ll#L68:L71
t2: i32,ch = CopyFromReg t0, Register:i32 %0 t21: i16 = truncate t2 t22: i16 = sign_extend_inreg t21, ValueType:ch:i8 t53: i32 = sign_extend t22
; X64-NEXT: movsbl %dil, %eax ; X64-NEXT: movsbl %sil, %ecx ; X64-NEXT: movswl %cx, %esi ; <-- ECX IS ALREADY SIGN-EXTENDED FROM i8 ; X64-NEXT: movswl %ax, %ecx ; <-- EAX IS ALREADY SIGN-EXTENDED FROM i8
Specialize the transform, which avoids problems with the transform creating an infinite loop.
Make sure we materialize improvements in sdiv_fix.