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

Omkar Mohanty via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 1 05:09:20 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
----------------
omkar-mohanty wrote:

Could the `xor %edx, %edx` be considered redundant here?
Since we’re truncating to a 32-bit subtraction and the high bits are known to be zero, and if  we remove the redundant `sbb`, is there still a reason to explicitly clear edx?

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


More information about the llvm-commits mailing list