Index: llvm/lib/Target/X86/X86FastISel.cpp =================================================================== --- llvm/lib/Target/X86/X86FastISel.cpp +++ llvm/lib/Target/X86/X86FastISel.cpp @@ -2092,14 +2092,6 @@ } } NeedTest = false; - } else if (foldX86XALUIntrinsic(CC, I, Cond)) { - // Fake request the condition, otherwise the intrinsic might be completely - // optimized away. - Register TmpReg = getRegForValue(Cond); - if (TmpReg == 0) - return false; - - NeedTest = false; } if (NeedTest) { Index: llvm/test/CodeGen/X86/pr54369.ll =================================================================== --- llvm/test/CodeGen/X86/pr54369.ll +++ llvm/test/CodeGen/X86/pr54369.ll @@ -1,16 +1,16 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py ; RUN: llc -mtriple=x86_64-- -O0 < %s | FileCheck %s -; FIXME: This is currently miscompiled due to an eflags clobber. define i64 @adder(i64 %lhs, i64 %rhs) { ; CHECK-LABEL: adder: ; CHECK: # %bb.0: ; CHECK-NEXT: addq %rsi, %rdi -; CHECK-NEXT: seto %al +; CHECK-NEXT: seto %dl ; CHECK-NEXT: xorl %eax, %eax ; CHECK-NEXT: # kill: def $rax killed $eax ; CHECK-NEXT: movl $148, %ecx -; CHECK-NEXT: cmovoq %rcx, %rax +; CHECK-NEXT: testb $1, %dl +; CHECK-NEXT: cmovneq %rcx, %rax ; CHECK-NEXT: retq %res = call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %lhs, i64 %rhs) %errorbit = extractvalue { i64, i1 } %res, 1 Index: llvm/test/CodeGen/X86/xaluo.ll =================================================================== --- llvm/test/CodeGen/X86/xaluo.ll +++ llvm/test/CodeGen/X86/xaluo.ll @@ -563,7 +563,9 @@ ; FAST-NEXT: movl %esi, %eax ; FAST-NEXT: movl %edi, %ecx ; FAST-NEXT: addl %esi, %ecx -; FAST-NEXT: cmovol %edi, %eax +; FAST-NEXT: seto %cl +; FAST-NEXT: testb $1, %cl +; FAST-NEXT: cmovnel %edi, %eax ; FAST-NEXT: retq %t = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %v1, i32 %v2) %obit = extractvalue {i32, i1} %t, 1 @@ -585,7 +587,9 @@ ; FAST-NEXT: movq %rsi, %rax ; FAST-NEXT: movq %rdi, %rcx ; FAST-NEXT: addq %rsi, %rcx -; FAST-NEXT: cmovoq %rdi, %rax +; FAST-NEXT: seto %cl +; FAST-NEXT: testb $1, %cl +; FAST-NEXT: cmovneq %rdi, %rax ; FAST-NEXT: retq %t = call {i64, i1} @llvm.sadd.with.overflow.i64(i64 %v1, i64 %v2) %obit = extractvalue {i64, i1} %t, 1 @@ -607,7 +611,9 @@ ; FAST-NEXT: movl %esi, %eax ; FAST-NEXT: movl %edi, %ecx ; FAST-NEXT: addl %esi, %ecx -; FAST-NEXT: cmovbl %edi, %eax +; FAST-NEXT: setb %cl +; FAST-NEXT: testb $1, %cl +; FAST-NEXT: cmovnel %edi, %eax ; FAST-NEXT: retq %t = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %v1, i32 %v2) %obit = extractvalue {i32, i1} %t, 1 @@ -629,7 +635,9 @@ ; FAST-NEXT: movq %rsi, %rax ; FAST-NEXT: movq %rdi, %rcx ; FAST-NEXT: addq %rsi, %rcx -; FAST-NEXT: cmovbq %rdi, %rax +; FAST-NEXT: setb %cl +; FAST-NEXT: testb $1, %cl +; FAST-NEXT: cmovneq %rdi, %rax ; FAST-NEXT: retq %t = call {i64, i1} @llvm.uadd.with.overflow.i64(i64 %v1, i64 %v2) %obit = extractvalue {i64, i1} %t, 1 @@ -649,7 +657,9 @@ ; FAST: ## %bb.0: ; FAST-NEXT: movl %esi, %eax ; FAST-NEXT: cmpl %esi, %edi -; FAST-NEXT: cmovol %edi, %eax +; FAST-NEXT: seto %cl +; FAST-NEXT: testb $1, %cl +; FAST-NEXT: cmovnel %edi, %eax ; FAST-NEXT: retq %t = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %v1, i32 %v2) %obit = extractvalue {i32, i1} %t, 1 @@ -669,7 +679,9 @@ ; FAST: ## %bb.0: ; FAST-NEXT: movq %rsi, %rax ; FAST-NEXT: cmpq %rsi, %rdi -; FAST-NEXT: cmovoq %rdi, %rax +; FAST-NEXT: seto %cl +; FAST-NEXT: testb $1, %cl +; FAST-NEXT: cmovneq %rdi, %rax ; FAST-NEXT: retq %t = call {i64, i1} @llvm.ssub.with.overflow.i64(i64 %v1, i64 %v2) %obit = extractvalue {i64, i1} %t, 1 @@ -689,7 +701,9 @@ ; FAST: ## %bb.0: ; FAST-NEXT: movl %esi, %eax ; FAST-NEXT: cmpl %esi, %edi -; FAST-NEXT: cmovbl %edi, %eax +; FAST-NEXT: setb %cl +; FAST-NEXT: testb $1, %cl +; FAST-NEXT: cmovnel %edi, %eax ; FAST-NEXT: retq %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %v1, i32 %v2) %obit = extractvalue {i32, i1} %t, 1 @@ -709,7 +723,9 @@ ; FAST: ## %bb.0: ; FAST-NEXT: movq %rsi, %rax ; FAST-NEXT: cmpq %rsi, %rdi -; FAST-NEXT: cmovbq %rdi, %rax +; FAST-NEXT: setb %cl +; FAST-NEXT: testb $1, %cl +; FAST-NEXT: cmovneq %rdi, %rax ; FAST-NEXT: retq %t = call {i64, i1} @llvm.usub.with.overflow.i64(i64 %v1, i64 %v2) %obit = extractvalue {i64, i1} %t, 1 @@ -1089,10 +1105,12 @@ ; FAST-LABEL: incovfselectstore: ; FAST: ## %bb.0: ; FAST-NEXT: movl %esi, %eax -; FAST-NEXT: movl %edi, %ecx -; FAST-NEXT: incl %ecx -; FAST-NEXT: cmovol %edi, %eax -; FAST-NEXT: movl %ecx, (%rdx) +; FAST-NEXT: movl %edi, %esi +; FAST-NEXT: incl %esi +; FAST-NEXT: seto %cl +; FAST-NEXT: testb $1, %cl +; FAST-NEXT: cmovnel %edi, %eax +; FAST-NEXT: movl %esi, (%rdx) ; FAST-NEXT: retq %t = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %v1, i32 1) %obit = extractvalue {i32, i1} %t, 1 @@ -1116,10 +1134,12 @@ ; FAST-LABEL: decovfselectstore: ; FAST: ## %bb.0: ; FAST-NEXT: movl %esi, %eax -; FAST-NEXT: movl %edi, %ecx -; FAST-NEXT: decl %ecx -; FAST-NEXT: cmovol %edi, %eax -; FAST-NEXT: movl %ecx, (%rdx) +; FAST-NEXT: movl %edi, %esi +; FAST-NEXT: decl %esi +; FAST-NEXT: seto %cl +; FAST-NEXT: testb $1, %cl +; FAST-NEXT: cmovnel %edi, %eax +; FAST-NEXT: movl %esi, (%rdx) ; FAST-NEXT: retq ; ; KNL-LABEL: decovfselectstore: Index: llvm/test/CodeGen/X86/xmulo.ll =================================================================== --- llvm/test/CodeGen/X86/xmulo.ll +++ llvm/test/CodeGen/X86/xmulo.ll @@ -516,13 +516,23 @@ ; Check the use of the overflow bit in combination with a select instruction. ; define i32 @smuloselecti32(i32 %v1, i32 %v2) { -; LINUX-LABEL: smuloselecti32: -; LINUX: # %bb.0: -; LINUX-NEXT: movl %esi, %eax -; LINUX-NEXT: movl %edi, %ecx -; LINUX-NEXT: imull %esi, %ecx -; LINUX-NEXT: cmovol %edi, %eax -; LINUX-NEXT: retq +; SDAG-LABEL: smuloselecti32: +; SDAG: # %bb.0: +; SDAG-NEXT: movl %esi, %eax +; SDAG-NEXT: movl %edi, %ecx +; SDAG-NEXT: imull %esi, %ecx +; SDAG-NEXT: cmovol %edi, %eax +; SDAG-NEXT: retq +; +; FAST-LABEL: smuloselecti32: +; FAST: # %bb.0: +; FAST-NEXT: movl %esi, %eax +; FAST-NEXT: movl %edi, %ecx +; FAST-NEXT: imull %esi, %ecx +; FAST-NEXT: seto %cl +; FAST-NEXT: testb $1, %cl +; FAST-NEXT: cmovnel %edi, %eax +; FAST-NEXT: retq ; ; WIN64-LABEL: smuloselecti32: ; WIN64: # %bb.0: @@ -550,13 +560,23 @@ } define i64 @smuloselecti64(i64 %v1, i64 %v2) { -; LINUX-LABEL: smuloselecti64: -; LINUX: # %bb.0: -; LINUX-NEXT: movq %rsi, %rax -; LINUX-NEXT: movq %rdi, %rcx -; LINUX-NEXT: imulq %rsi, %rcx -; LINUX-NEXT: cmovoq %rdi, %rax -; LINUX-NEXT: retq +; SDAG-LABEL: smuloselecti64: +; SDAG: # %bb.0: +; SDAG-NEXT: movq %rsi, %rax +; SDAG-NEXT: movq %rdi, %rcx +; SDAG-NEXT: imulq %rsi, %rcx +; SDAG-NEXT: cmovoq %rdi, %rax +; SDAG-NEXT: retq +; +; FAST-LABEL: smuloselecti64: +; FAST: # %bb.0: +; FAST-NEXT: movq %rsi, %rax +; FAST-NEXT: movq %rdi, %rcx +; FAST-NEXT: imulq %rsi, %rcx +; FAST-NEXT: seto %cl +; FAST-NEXT: testb $1, %cl +; FAST-NEXT: cmovneq %rdi, %rax +; FAST-NEXT: retq ; ; WIN64-LABEL: smuloselecti64: ; WIN64: # %bb.0: @@ -648,13 +668,23 @@ } define i32 @umuloselecti32(i32 %v1, i32 %v2) { -; LINUX-LABEL: umuloselecti32: -; LINUX: # %bb.0: -; LINUX-NEXT: movl %edi, %eax -; LINUX-NEXT: mull %esi -; LINUX-NEXT: cmovol %edi, %esi -; LINUX-NEXT: movl %esi, %eax -; LINUX-NEXT: retq +; SDAG-LABEL: umuloselecti32: +; SDAG: # %bb.0: +; SDAG-NEXT: movl %edi, %eax +; SDAG-NEXT: mull %esi +; SDAG-NEXT: cmovol %edi, %esi +; SDAG-NEXT: movl %esi, %eax +; SDAG-NEXT: retq +; +; FAST-LABEL: umuloselecti32: +; FAST: # %bb.0: +; FAST-NEXT: movl %edi, %eax +; FAST-NEXT: mull %esi +; FAST-NEXT: seto %al +; FAST-NEXT: testb $1, %al +; FAST-NEXT: cmovnel %edi, %esi +; FAST-NEXT: movl %esi, %eax +; FAST-NEXT: retq ; ; WIN64-LABEL: umuloselecti32: ; WIN64: # %bb.0: @@ -686,13 +716,23 @@ } define i64 @umuloselecti64(i64 %v1, i64 %v2) { -; LINUX-LABEL: umuloselecti64: -; LINUX: # %bb.0: -; LINUX-NEXT: movq %rdi, %rax -; LINUX-NEXT: mulq %rsi -; LINUX-NEXT: cmovoq %rdi, %rsi -; LINUX-NEXT: movq %rsi, %rax -; LINUX-NEXT: retq +; SDAG-LABEL: umuloselecti64: +; SDAG: # %bb.0: +; SDAG-NEXT: movq %rdi, %rax +; SDAG-NEXT: mulq %rsi +; SDAG-NEXT: cmovoq %rdi, %rsi +; SDAG-NEXT: movq %rsi, %rax +; SDAG-NEXT: retq +; +; FAST-LABEL: umuloselecti64: +; FAST: # %bb.0: +; FAST-NEXT: movq %rdi, %rax +; FAST-NEXT: mulq %rsi +; FAST-NEXT: seto %al +; FAST-NEXT: testb $1, %al +; FAST-NEXT: cmovneq %rdi, %rsi +; FAST-NEXT: movq %rsi, %rax +; FAST-NEXT: retq ; ; WIN64-LABEL: umuloselecti64: ; WIN64: # %bb.0: