diff options
author | Sanjay Patel <spatel@rotateright.com> | 2017-03-02 17:18:56 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2017-03-02 17:18:56 +0000 |
commit | fffa17983756af40fb726b425a314091767f1388 (patch) | |
tree | adc3d656b9535f4ffb2cc4ab03f909a88fb092df /llvm/test/CodeGen/X86/select_const.ll | |
parent | 6ab2d4891eeea6e4a928134893632de47093e132 (diff) | |
download | bcm5719-llvm-fffa17983756af40fb726b425a314091767f1388.tar.gz bcm5719-llvm-fffa17983756af40fb726b425a314091767f1388.zip |
[DAGCombiner] avoid assertion when folding binops with opaque constants
This bug was introduced with:
https://reviews.llvm.org/rL296699
There may be a way to loosen the restriction, but for now just bail out
on any opaque constant.
The tests show that opacity is target-specific. This goes back to cost
calculations in ConstantHoisting based on TTI->getIntImmCost().
llvm-svn: 296768
Diffstat (limited to 'llvm/test/CodeGen/X86/select_const.ll')
-rw-r--r-- | llvm/test/CodeGen/X86/select_const.ll | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/select_const.ll b/llvm/test/CodeGen/X86/select_const.ll index c19060e6bcf..716ee70d926 100644 --- a/llvm/test/CodeGen/X86/select_const.ll +++ b/llvm/test/CodeGen/X86/select_const.ll @@ -291,3 +291,29 @@ define <2 x double> @sel_constants_fmul_constant_vec(i1 %cond) { %bo = fmul <2 x double> %sel, <double 5.1, double 3.14> ret <2 x double> %bo } + +; 4294967297 = 0x100000001. +; This becomes an opaque constant via ConstantHoisting, so we don't fold it into the select. + +define i64 @opaque_constant(i1 %cond, i64 %x) { +; CHECK-LABEL: opaque_constant: +; CHECK: # BB#0: +; CHECK-NEXT: testb $1, %dil +; CHECK-NEXT: movl $23, %ecx +; CHECK-NEXT: movq $-4, %rax +; CHECK-NEXT: cmoveq %rcx, %rax +; CHECK-NEXT: movabsq $4294967297, %rcx # imm = 0x100000001 +; CHECK-NEXT: andq %rcx, %rax +; CHECK-NEXT: xorl %edx, %edx +; CHECK-NEXT: cmpq %rcx, %rsi +; CHECK-NEXT: sete %dl +; CHECK-NEXT: subq %rdx, %rax +; CHECK-NEXT: retq + %sel = select i1 %cond, i64 -4, i64 23 + %bo = and i64 %sel, 4294967297 + %cmp = icmp eq i64 %x, 4294967297 + %sext = sext i1 %cmp to i64 + %add = add i64 %bo, %sext + ret i64 %add +} + |