[llvm] [DAG] Generalize setcc(setcc) fold to use known bits. (PR #66503)

David Green via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 16 09:00:38 PST 2024


================
@@ -403,14 +403,19 @@ define i32 @PR17487(i1 %tobool) {
 ;
 ; X64-LIN-LABEL: PR17487:
 ; X64-LIN:       # %bb.0:
-; X64-LIN-NEXT:    movl %edi, %eax
-; X64-LIN-NEXT:    andl $1, %eax
+; X64-LIN-NEXT:    movd %edi, %xmm0
+; X64-LIN-NEXT:    pshufd {{.*#+}} xmm0 = xmm0[0,1,0,1]
+; X64-LIN-NEXT:    pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; X64-LIN-NEXT:    pextrw $4, %xmm0, %eax
 ; X64-LIN-NEXT:    retq
 ;
 ; X64-WIN-LABEL: PR17487:
 ; X64-WIN:       # %bb.0:
-; X64-WIN-NEXT:    andb $1, %cl
 ; X64-WIN-NEXT:    movzbl %cl, %eax
+; X64-WIN-NEXT:    movd %eax, %xmm0
+; X64-WIN-NEXT:    pshufd {{.*#+}} xmm0 = xmm0[0,1,0,1]
+; X64-WIN-NEXT:    pand __xmm at 00000000000000010000000000000001(%rip), %xmm0
+; X64-WIN-NEXT:    pextrw $4, %xmm0, %eax
----------------
davemgreen wrote:

Hi. Unfortunately I think this might always been a bit too far down the todo list to get to any time soon. If you happen to have improvements for it that would useful.

I do think though, in my opinion, that this shouldn't be considered the kind of change that should block for the patch. After all it is optimized away by instcombine (https://godbolt.org/z/P4vMYd5oc), it was added to protect against a crash and still does not crash, we don't have any evidence of it coming up in practice, and most importantly it gets optimized away by instcombine. It sounds like you think otherwise though, and you think it might be more important.

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


More information about the llvm-commits mailing list