[llvm] [X86] Truncate i64 sub to i32 when upper 33 bits are zeros (PR #145850)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 26 04:00:16 PDT 2025


================
@@ -0,0 +1,78 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefix=X64
+
+; Truncate to 32 bit subtraction since first 48 bits are zeros
+define i64 @test1(i16 %a, i16 %b) nounwind {
+; X86-LABEL: test1:
+; X86:       # %bb.0:
+; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:    xorl %edx, %edx
+; X86-NEXT:    subl %ecx, %eax
+; X86-NEXT:    sbbl %edx, %edx
----------------
RKSimon wrote:

Why didn't the 32-bit target  recognize that the SBB was redundant?

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


More information about the llvm-commits mailing list